Skip to main content

Errors

The Docyard API uses conventional HTTP status codes to indicate success or failure. Codes in the 2xx range indicate success. Codes in the 4xx range indicate a client error. Codes in the 5xx range indicate a server error.

Error Response Format

All error responses follow this structure:
{
  "statusCode": 400,
  "message": "Domain 'example.com' is already registered to another dock",
  "error": "Bad Request"
}
FieldTypeDescription
statusCodeintegerHTTP status code
messagestringHuman-readable explanation of the error
errorstringHTTP status text

HTTP Status Codes

Success Codes

CodeMeaning
200Request succeeded
201Resource created successfully

Client Error Codes

CodeMeaningCommon Causes
400Bad RequestValidation failure, duplicate domain, invalid field format
401UnauthorizedMissing or invalid API key
403ForbiddenKey lacks permission for this dock or resource
404Not FoundDock, artifact, recipient, policy, or job does not exist
409ConflictResource already exists (e.g., duplicate email in dock)
422Unprocessable EntityRequest is well-formed but semantically invalid
429Too Many RequestsRate limit exceeded — check Retry-After header

Server Error Codes

CodeMeaning
500Internal Server Error
503Service Unavailable

Validation Errors

When request body validation fails, the message field contains an array of specific validation errors:
{
  "statusCode": 400,
  "message": [
    "name must be a string",
    "email must be an email"
  ],
  "error": "Bad Request"
}
The API uses a whitelist validation strategy. Unknown fields in the request body are silently stripped — they do not cause errors, but they are not stored.

Handling Errors

Implement idempotent retry logic for transient failures (5xx, 429):
async function docyardRequest(url, options, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    const response = await fetch(url, options);

    if (response.ok) return response.json();

    if (response.status === 429 || response.status >= 500) {
      const retryAfter = response.headers.get('Retry-After') || 2 ** attempt;
      await new Promise(r => setTimeout(r, retryAfter * 1000));
      continue;
    }

    // Client errors — do not retry
    const error = await response.json();
    throw new Error(`${error.statusCode}: ${error.message}`);
  }

  throw new Error('Max retries exceeded');
}
Never retry 4xx errors (except 429). These indicate a problem with your request that retrying will not fix.