Error Handling
Practical guidance for handling failures: authentication, validation, resource and temporary problems.
1. Check the HTTP response
Inspect the HTTP status of every response before processing the body. Non-successful statuses indicate the request failed.
2. Check success
Where the response includes a success field, verify it before trusting the payload. A response with success: false should be treated as an error even if the HTTP layer looks fine.
3. Log the request_id
Log the request_id returned in the response envelope. It's the correlation identifier Undersign support uses to trace a request.
4. Log endpoint and transaction
Log the endpoint you called and your own internal transaction ID alongside the request_id so failures are traceable in both directions.
5. Handle failure categories
- Authentication failures: the credential is missing, malformed or inactive. Fix the credential; do not retry blindly.
- Validation failures: the request body is invalid. Inspect the response and correct the request before retrying.
- Resource failures: for example a template or request isn't found. Verify the identifier before retrying.
- Temporary failures: transient problems. Retry with an appropriate delay.
6. Avoid infinite retries
Cap retries and back off with increasing delays. See Rate Limits for operational guidance.
7. Error code reference
Every failure carries an error.code. Handle the code, not just the HTTP status:
| Error code | HTTP | Meaning |
|---|---|---|
| TEMPLATES_REQUIRED | 400 | templates empty or missing on create. |
| SIGNER_COUNT_MISMATCH | 400 | Signer count does not match the template requirement. |
| SIGNER_ORDER_MISMATCH | 400 | Same-position signers differ across templates in sequential mode. |
| PROCESSING_ERROR | 400 | Database transaction or storage copy failure. |
| VALIDATION_ERROR | 400 | Bulk request has an empty templates or requests array. |
| BATCH_SIZE_EXCEEDED | 400 | Bulk requests array exceeds 100 items. |
| INVALID_SIGNER_DATA | 400 | Missing name or email in a bulk signer row. |
| INVALID_EMAIL | 400 | Invalid email format in a bulk signer row. |
| CREATE_LINK_FAILED | 400 | Public link could not be created (database error). |
| VALIDATION_FAILED | 422 | Public link payload invalid; inspect error.details. |
| MONTHLY_API_QUOTA_EXCEEDED | 403 | Monthly API credits exhausted. |
| CREDIT_LIMIT_REACHED | 403 | Insufficient API credits for a bulk batch. |
| STORAGE_LIMIT_EXCEEDED | 403 | Account storage quota exceeded. |
| TEMPLATE_NOT_FOUND | 404 | Template UUID not found, deleted, or draft. |
| PACKAGE_NOT_FOUND | 404 | Signature request not found. |
| LINK_NOT_FOUND | 404 | Public link missing or owned by another company. |
| RATE_LIMIT_EXCEEDED | 429 | More than 100 requests per minute. |
Example check
const response = await fetch(url, options);
const data = await response.json();
if (!response.ok || data.success === false) {
console.error({
status: response.status,
requestId: data.request_id
});
return;
}