Test your integration
Test your integration in an Account used only for development and automated tests. An Account keeps credentials, Workplaces, Persons, work, Documents, Decisions and webhook endpoints separate from production.
The API has no test mode flag. Use a separate Account to keep test data out of production, and use dry runs when you only want to see a Decision without storing work.
Set up a test Account
Section titled “Set up a test Account”- Use an Account only for development. Contact
hello@dockt.comif you need another one. - Create an API key with only the permissions your tests need.
- Write the same Policies you plan to use in production, and create test Workplaces.
- Register a webhook endpoint owned by your test environment.
- Use fictional worker data, or data you are allowed to process.
- Keep every
external_refand idempotency key free of personal data.
Don’t run automated tests in your production Account. Decisions are kept as history, and test Persons would count as usage.
Separate parser tests from workflow tests
Section titled “Separate parser tests from workflow tests”Use two kinds of tests:
- Contract tests check that your code handles every documented response shape and value.
- Workflow tests check authentication, references, uploads, asynchronous Decisions, webhook delivery and recovery against the API.
Don’t require an uploaded file to produce one exact result in every automated run. Document reading and registry answers can change. Assert on your handling of each result instead, and keep reviewed fixtures for the shapes you parse.
Build fixtures from the schemas in OpenAPI JSON, or record responses from your test Account and remove personal data. Store them with your tests and update them in a reviewed change, not during every build.
Test the API boundary
Section titled “Test the API boundary”| Case | Expected behavior |
|---|---|
| Valid credential | GET /v1/auth/me returns your Account and the expected permissions. |
| Missing bearer token | 401 with Problem Details. |
| Missing permission | 403 with Problem Details. |
Same external_ref sent twice for a Person, Company, Workplace, or Assignment |
The second call updates the matching record and returns 200. |
Document uploaded with an existing external_ref |
Dockt returns the existing Document unchanged with 200. |
| Same idempotency key and request | Dockt replays the first response. |
| Same idempotency key with a changed body | 409 idempotency conflict. |
| Unknown attribute code | 422 attribute-unknown. |
| Empty or unsupported upload | 400 invalid-document-upload. |
Record x-request-id when a test fails. Don’t record the credential or file contents.
Test asynchronous Decisions
Section titled “Test asynchronous Decisions”Check that your application:
- Stores the Assignment and Person IDs from the create response, while
latest_decisionis stillnull. - Handles
decision.createdfor bothassignmentandengagementtargets. - Handles all four results:
compliant,incomplete,review_requiredandnon_compliant. - Handles every requirement status, and doesn’t ask anyone for
pendingrequirements. - Treats an unfamiliar finding code by its
severity. - Sends values it already knows when the Decision has
input_requests, instead of asking users to fill in a form. - Stores the Decision ID it acted on, and notices when a later Decision replaces it.
- Shows a requirement turning
expiring_soon, so users can renew a document in time.
For Documents, check that your application handles processing, processed, failed and withdrawn, and doesn’t treat processed as “valid”.
Test webhook delivery
Section titled “Test webhook delivery”Send a signed test event with POST /v1/notification-destinations/{id}/test. Check that your receiver:
- Reads the raw body before parsing JSON.
- Rejects an invalid signature.
- Rejects a timestamp outside the five-minute replay window.
- Stores the event ID before applying side effects.
- Returns
2xxafter durable acceptance. - Treats a repeated event ID as an acknowledged duplicate.
The test event proves delivery and signature handling. It doesn’t create work or a Decision.
Test recovery
Section titled “Test recovery”Simulate failures in your own application:
- Drop a
decision.createdafter verification, then recover it withGET /v1/assignments?status=openand the Decision history. - Deliver the same event twice, then confirm the side effect runs once.
- Deliver two
decision.createdevents for the same work in reverse order, then confirm you keep the newest Decision. - Time out an upload, then retry with the same idempotency key and file.
- Leave work without a Decision past your own deadline, then confirm you keep it pending instead of inventing a result.
Finish with Prepare for production.