Use the AgentSync Platform API to programmatically retrieve your organization's contracts, contract assignments, producers, organizations, tasks and requirement sets. The API reference beside this guide documents every route, field and error code.
1. Get a credential
AgentSync support creates a service account for your organization and sends you its client ID and secret. The secret is shown only once, so store it in your secrets manager right away.
A credential belongs to one organization, and it is for a system, not a person. Every request must carry a token issued to a service account. You don't need a credential per team member.
If your client secret is exposed, contact AgentSync support to disable the service
account. Every call made with it then fails with 403 role_missing within five minutes.
2. Request an access token
Use the OAuth 2.0 client-credentials flow, and ask for only the scopes you need. Reuse the token until it expires.
curl -s https://auth.sandbox.agentsync.io/oauth2/token \
-u "$CLIENT_ID:$CLIENT_SECRET" \
-d grant_type=client_credentials \
--data-urlencode scope="platform.contracts.read platform.contract-assignments.read"
Each route needs one scope. A token without that route's scope is refused with
403 scope_missing.
| Scope | Routes |
|---|---|
platform.contracts.read | GET /v1/contracts |
platform.contract-assignments.read | GET /v1/contract-assignments, GET /v1/contract-assignments/{id}, GET /v1/access-overrides |
platform.producers.read | GET /v1/producers, GET /v1/producers/{id} |
platform.organizations.read | GET /v1/organizations |
platform.tasks.read | GET /v1/tasks, GET /v1/tasks/{id}, GET /v1/tasks/{id}/files/{slot} |
platform.requirement-sets.read | GET /v1/requirement-sets, GET /v1/requirement-sets/{id} |
3. Make your first call
The base URL is https://api.<environment>.agentsync.io/platform, and every path
begins with /v1. The examples on this page use the sandbox environment.
curl -s https://api.sandbox.agentsync.io/platform/v1/contracts \
-H "Authorization: Bearer $ACCESS_TOKEN"
If a call is rejected because of the token or the service account, the error code tells you why.
| Status | Code | What it means |
|---|---|---|
401 | token_invalid | The request has no valid token. Every /v1 path returns this without a valid token, even a path that doesn't exist, so check the path before the credential. |
403 | caller_not_service_account | The token was issued to a person. Use a token issued to a service account. |
403 | caller_claims_missing | The token is missing the organization or service account the API reads from it. Contact support. |
403 | scope_missing | The token doesn't have the scope the route requires. Request a token with that scope. |
403 | role_missing | Support revoked the service account's role or disabled the account. Every call returns this within five minutes of the change. |
4. Read every page
A list returns an items array and a page object. To read every page:
- While
pagecarries anextToken, send it back aspage_token, with the same filters, to read the next page. - Stop when
pagehas nonextToken.
Page size: page_size defaults to 50, and a value above 200 is lowered to 200.
GET /v1/organizations lowers any value above 50 to 50.
Page tokens: Treat page_token as opaque. It is at most 1024 bytes. A token that
is altered, sent with other filters, or no longer valid answers 400 parameter_invalid
on page_token. Start again from the first page.
5. Handle errors
Every error puts its code in the first entry of the details array. Branch on that
code, not on the message. If there's no code, use the HTTP status.
{
"message": "invalid page_size",
"details": [
{ "param": "code", "message": "parameter_invalid" },
{ "param": "page_size", "message": "must be a positive integer" }
]
}
Two responses can arrive without a code:
500: The body may be empty or have only a message. Treat it asinternal_error.429from the API gateway: The body has only a message. Treat any429as a signal to slow down.
Retry a 429 or a 503 with backoff.
A 404 producer_not_found doesn't always mean the ID is wrong. A producer is visible
only while they hold a contract assignment under your contracts that isn't terminated,
or an active producer role at your organization; once neither holds, the producer
answers the same 404 as an unknown ID. GET /v1/contract-assignments still lists
their terminated assignments.
6. Get notified of changes (webhooks)
AgentSync can notify your system of changes through webhooks. The AgentSync event catalog lists the event types. To subscribe, ask AgentSync support for a link to the webhook portal. There you register your HTTPS endpoint, choose the event types you want, and find the endpoint's signing secret. Use that secret to verify each webhook's signature before you process it, as the Webhooks Quick Start Guide describes.
Data can lag behind an event. A change is normally readable through the API within a few seconds of its event. If it isn't, retry with backoff for up to about a minute. Re-read the records you hold from time to time to catch anything an event didn't carry.
7. Versioning
Version 1 (/v1) only adds things: new operations, optional parameters, response
fields, error codes and enum values. Nothing is removed, renamed or changed in meaning.
Ignore response fields you don't recognize. If you get an error code or enum value you
don't recognize, handle it by its HTTP status. Breaking changes are announced in
advance.