Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.swisstools.dev/llms.txt

Use this file to discover all available pages before exploring further.

All errors from the Swisstools API return a JSON body with a single error field containing a human-readable message. The HTTP status code tells you the category of the problem. There are no nested error objects or machine-readable error codes beyond the status code itself.

Error Response Shape

Every error response looks like this:
{"error": "Unauthorized"}
The Content-Type header is always application/json, even for error responses.

HTTP Status Codes

StatusMeaning
400 Bad RequestThe request body is missing required fields or contains invalid values. Fix the input and retry.
401 UnauthorizedNo valid session cookie or API key was supplied. Authenticate and retry.
403 ForbiddenYou are authenticated but do not have permission to access this resource.
404 Not FoundThe resource you requested does not exist, or has been deleted.
405 Method Not AllowedYou used an HTTP method that is not supported on this endpoint (e.g., POST on a read-only route).
500 Internal Server ErrorSomething went wrong on our end. If this persists, contact support.

Example Error Responses

400 — missing required field:
{"error": "Name is required"}
401 — unauthenticated request:
{"error": "Unauthorized"}
404 — resource not found:
{"error": "Not found"}
405 — wrong HTTP method:
{"error": "Method not allowed"}

Handling Errors in Code

Check res.ok before reading the response body. When res.ok is false, parse the JSON and surface the error string to your users or logs.
const res = await fetch('https://swisstools.dev/api/projects/proj-id/mocks', {
  headers: { 'Cookie': sessionCookie }
});

if (!res.ok) {
  const { error } = await res.json();
  console.error('API error:', error);
  // Handle specific status codes
  if (res.status === 401) {
    // Redirect to login
  } else if (res.status === 404) {
    // Show not-found UI
  }
}
import requests

res = requests.get(
    'https://swisstools.dev/api/projects/proj-id/mocks',
    cookies={'session': session_token}
)

if not res.ok:
    error = res.json().get('error')
    print(f'API error {res.status_code}: {error}')