Prastav API Contract Standard V1
Use versioned customer APIs with bounded queries, strong revisions, optional idempotency and external record identity.
Use this contract with the supported operation catalogue and Scalar reference. The feature API version is /api/v1. Existing human, OAuth, developer-management and unversioned application routes keep their contracts. Documentation archive dates are separate from API compatibility. See the deployed reference for availability of the matching source contract.
Current HTTP behavior
GET reads supported resources; POST performs the specific registration, issuance, authentication or consent command; PUT changes the specified settings or scope; DELETE revokes the specified credential. A method name alone does not make a command safe to replay. Businesses, Contacts and Leads publish versioned list/get/create/update. The legacy GET Businesses remains compatible. The Customers V1 expansion additionally publishes native activities, scheduling, lifecycle/configuration, file jobs and safe assistance; unrelated modules and private provider orchestration remain excluded.
| Status | Current meaning and next action |
|---|---|
| 200 OK | Read or command completed with the operation's documented representation. API key/client issuance returns 200 and reveal-once credential data. Protect that response. |
| 201 Created | The application-registration controller creates a registration and returns its representation with Location. Versioned native creates also return an identity representation and Location. |
| 204 No Content | Settings/scope updates and credential/grant revocations return no body in their current controllers. Do not require JSON after this status. |
| 302 Found | OAuth authorization continues to sign-in or the validated callback. This redirect is not an access token or automatic consent. |
| 400 Bad Request | Invalid fields, stale/invalid OAuth proof or another action-specific request error. Inspect the appropriate response family. |
| 401 Unauthorized | Authentication is missing, invalid, expired or revoked. Check the required identity and acquire valid authentication through its supported flow. |
| 403 Forbidden | Authentication was recognized, but current permission, scope, resource grant, membership, application approval or subscription policy does not permit the operation. Refreshing a valid token alone does not grant access. |
| 404 Not Found | The requested route/resource is unavailable within the caller's authorized context. Do not probe other workspaces or infer whether another tenant owns that identifier. Some management ownership checks deliberately deny with 403 instead. |
| 409 Conflict | The supplied application, client or grant revision is stale. Reload, reconcile the intended change, and obtain a new explicit decision. |
| 412 Precondition Failed | The strong If-Match revision is stale, weak or belongs to another record. Read/review the current resource. |
| 428 Precondition Required | Supply the current GET ETag in If-Match for a versioned update. |
| 413 Content Too Large | The configured or operation body limit was exceeded. Reduce the request. |
| 415 Unsupported Media Type | Match the operation's JSON or form content type. The two OAuth token endpoints use different contracts. |
| 429 Too Many Requests | A configured rate/OTP limit applies. Wait for Retry-After when supplied; OTP limits do not universally supply that header. |
| 500 / 502 / 503 | Unexpected server failure, upstream integration failure or temporary unavailability, depending on the operation. Retain safe references and inspect an uncertain write before repeating it. |
Customers file imports/exports now expose real durable batch/job status and results using their native 200 response contracts. Queued is not completed. No blanket 202 Accepted or generic incoming API queue is introduced; see durable jobs.
Response metadata compatibility
Application registration is documented as 201. Settings and client-scope changes plus the four credential/grant revocation commands are documented as 204 with no body, matching their established controllers. The seven prior 200 metadata discrepancies are corrected without changing those wire responses. OAuth and OTP retain their distinct protocol/error mappings.
Current error response families
There is no universally implemented error envelope. Branch on HTTP status and the actual response shape. Read text safely when the body is empty, non-JSON or supplied by a proxy; never render it as trusted HTML.
The shared application error has code, a safe human message, correlationId and details containing field/message pairs. For example, the opted-in Businesses authentication boundary can return this artificial failure:
{
"code": "invalid_credentials",
"message": "A valid active credential or account session is required.",
"correlationId": "EXAMPLE_REQUEST_ID",
"details": []
}
Validation has a separate validation_failed body with an errors dictionary. Each field entry has code, messageKey and arguments. The following illustrates that shape, not a guaranteed validation result for every operation:
{
"code": "validation_failed",
"message": "One or more validation errors occurred.",
"errors": {
"Name": [{"code": "validation_required", "messageKey": "Validation.Required", "arguments": []}]
}
}
OAuth protocol failures use error and optional error_description. The legacy JSON token endpoint can return a message-only body. Integration application throttling returns code, message and maxRequestsPerMinute, with positive Retry-After seconds. Some bearer challenges have no body. The shared envelope, validation dictionary, OAuth response and rate-limit response must remain distinguishable.
Existing application codes
| Code | Meaning and appropriate action |
|---|---|
| invalid_credentials | Missing/invalid authentication; on Businesses, also inspect credential expiry/revocation and the declared scheme. Never switch to another person's credential. |
| insufficient_access | The opted-in business boundary recognized authentication but denied effective access. Review approvals, saved scope, user authority and subscription. |
| forbidden | An application-level authority/ownership check denied the operation. Ask the appropriate administrator; do not probe other identifiers. |
| not_found | An application resource was not found in the permitted context. Recheck the selected resource and workspace. |
| conflict | A revision or competing-state conflict. Reload and reconcile; do not reuse a stale request automatically. |
| validation_failed | Correct the named fields using the field-level error entries. |
| invalid_otp / expired_otp | Correct the code or restart through the offered challenge/recovery flow. Preserve leading zeroes. |
| otp_resend_cooldown / otp_resend_limit / otp_attempts_exceeded | Respect the server's resend/attempt restriction. Reloading does not reset it. |
| otp_delivery_failed | Delivery is unavailable; retain the safe reference and follow recovery rather than repeatedly sending. |
| internal_server_error | The shared exception handler hides internal details. Retain status, time and correlation/request identifiers for support. |
Existing field codes are validation_required, validation_invalid_format, validation_max_length, validation_min_length, validation_password_complexity, validation_password_mismatch, validation_duplicate, validation_business_rule, validation_invalid_value and validation_collection_required. Their applicability depends on the action. Do not parse a translated message or invent a new application code for an empty response. See authentication and access recovery.
Pagination, filters and success examples
GET Businesses uses one-based page and pageSize (default 10). Page below 1 becomes 1. Valid page sizes are 1 through 100; an out-of-range size resets to 10. Responses report the effective page, pageSize, totalCount and items. An empty authorized list is a successful response:
{"items": [], "page": 1, "pageSize": 10, "totalCount": 0}
Advance pages using the returned metadata. Concurrent changes can alter counts and offset pages; this API does not promise a snapshot/cursor export. Registration and authorization list operations instead return arrays, not this envelope.
The Businesses query supports search, status (own/external/all), recordStatus (active/inactive/all), contactStatus and gstinStatus (present/missing/all), sorting and documented location/date filters. The default record status is active. createdFrom is inclusive and createdUntil exclusive; use explicit UTC values. sortField=businessName and sortDirection=asc are supported. Inspect Scalar for the full parameter set; do not construct a SQL-like filter language or assume unknown filter values fail closed.
GET /api/businesses?page=1&pageSize=10&search=Example&recordStatus=active&sortField=businessName&sortDirection=asc
Accept: application/json
X-QX-Key: EXAMPLE_PUBLIC_ID.EXAMPLE_SECRET_REPLACE_ME
Use artificial values only. API access explains actual credential setup and request tools.
Correlation, concurrency and retries
Capture response X-Correlation-Id and X-Request-Id with method, safe route, UTC time and status. A caller may supply a correlation value of 1-80 ASCII letters/digits or -, _, ., :; unsafe values are replaced. Each HTTP request receives its own request ID. These values are diagnostic references, not authentication or deduplication keys. The Businesses fallback currently puts the request identifier in its body correlationId; the shared exception handler uses the correlation identifier. Keep both headers when reporting a problem.
Application settings use expectedVersion; client scope edits use expectedModifiedAtUtc; grant revocations use expectedVersion. Start from the latest returned representation. Versioned GUID updates adopt the strong ETag contract below; only the three versioned creates adopt optional Idempotency-Key. These headers do not change OAuth, consent, secret issuance or legacy commands. A normalized no-op still requires a current revision where that operation checks one.
Retry a safe read only with bounded attempts and backoff. For 429, wait at least the supplied Retry-After; without it, use bounded backoff and the operation's policy. Do not retry 400/401/403/409 unchanged. Correct the request, reacquire legitimate authentication, restore authority or reconcile the revision first. Authorization codes are single-use. A lost issuance response may hide a created reveal-once secret: inspect safe metadata and deliberately replace/revoke it. Do not blindly repeat registrations, OTP sends, consent decisions, payments or uncertain provider submissions.
Versioned create and update
POST /api/v1/businesses, /contacts or /leads accepts a wrapper:
{"record":{"businessName":"Example business"},"sourceId":null,"externalRecordId":null}
Use the matching record schema: Business/Contact native Upsert fields, or Lead title/description, captured fields, business/owner/contact/list IDs. Lead creation starts Pending with API origin; pipeline/stage/close fields are rejected. Human review owns acceptance and placement. Extra owner/list actions require the explicit conditional scopes. No public delete or lifecycle command is offered.
The 201 body contains id, entityType, revisionUtc, sourceId and externalRecordId; Location points to its versioned GET. GET detail and PUT return ETag. PUT sends the resource update body directly and one exact strong If-Match tag from GET. Missing tag is 428, stale/weak/foreign tag 412, malformed/multiple/wildcard tag 400. Check and write share the database transaction. An equal normalized update still checks the revision first.
Optional create idempotency
Ordinary creates work without a key. An optional Idempotency-Key is 1–128 visible ASCII characters, scoped to workspace/application-or-account/actor and resource create family. Key rotation or client replacement does not change application identity. Typed JSON property order/numeric format/default omission are canonicalized; strings, nulls and array order remain exact. Explicit source and external ID belong to the request semantics.
The same key and semantics returns the original committed identity with 201 and Idempotency-Replayed: true. Different semantics returns 409 idempotency_conflict. The native mutation, required audits, external binding and hashed-key outcome commit atomically. Simultaneous requests cannot create duplicate keyed records. A failed transaction permits retry; a lost postcommit response recovers the existing identity. Retained outcomes recheck current access and expire after seven days; the API host sweeps at most 1000 expired technical rows every minute with a ten-second budget, also covering inactive applications. Downtime/backlog delays physical removal without extending replay validity; after expiry the key can denote a new operation. External mapping uniqueness persists separately. Never depend on a key indefinitely.
There is no generic unsafe-method retry. Clients retain stable identities and own bounded scheduling. Unknown commit outcomes are not automatically repeated. Keep raw keys, credentials and private bodies out of logs. OAuth, OTP, consent, payments, one-time secrets and existing CommandId/RequestId operations use their own contracts.
External identity and defaults
Register sources through the application's Settings using an authorized human session. The source has a stable workspace SourceId and explicit application access. A provider label is not verified ownership. An external ID is opaque and case-sensitive, at most 256 characters with no control characters. EntityType is exactly Businesses, Contacts or Leads.
No externalRecordId creates no mapping.
externalRecordId plus sourceId uses that exact authorized source.
externalRecordId without sourceId uses only an explicitly configured application default; otherwise 400 external_source_required.
Invalid, inaccessible or retired explicit sources fail without fallback. Multiple sources do not imply a default.
One active source/entity/external ID maps to at most one canonical GUID. Existing bindings return 409 external_reference_already_bound on another create; no name/email/phone merge or overwrite occurs. GET /api/v1/external-references?sourceId=...&entityType=Businesses&externalRecordId=... returns only an authorized mapping. A keyed retry freezes its effective source even if the default later changes. Native GUID updates need no source. Authorized human reconciliation explicitly retires/replaces a conflicting mapping with revisions and audit; history survives native removal.
Bind a source to an existing GUID
Read the authorized source using GET /api/v1/external-references/source?entityType=Businesses&sourceId=SOURCE_GUID. Omit sourceId only to use the authenticated application's configured default. The response returns its current Version without exposing other application grants. Read the existing native GUID to obtain its strong ETag.
POST /api/v1/external-references with that ETag in If-Match:
{"entityType":"Businesses","prastavRecordId":"11111111-1111-4111-8111-111111111111","externalRecordId":"CUSTOMER-42","expectedSourceVersion":"22222222-2222-4222-8222-222222222222","sourceId":"33333333-3333-4333-8333-333333333333"}
These GUIDs are artificial. The selected entity needs current View and Update scopes plus the application's explicit source grant. Human sessions additionally require Integrations.Manage and an explicit SourceId. Lead ownership/ManageAny still applies. No new permission is added to an existing credential.
The result is 200 with the current mapping, for both first binding and an equal retry. It creates no duplicate native record and leaves native fields/revision unchanged. Equal binding keeps its own ID/version/timestamps with no extra audit; new binding and required audit commit atomically. Multiple sources can link the same GUID. A different target for an active identity conflicts and requires explicit administrator reconciliation. Missing native If-Match returns 428, stale native ETag 412, stale source Version 409. Current authority is rechecked after lock waits. Invalid/ungranted/retired sources never fall back to another source.
Retain the resolved SourceId for retries. A changed default does not silently match the earlier expected source Version. Lookup returns authorized historical identity evidence even if the native record was deleted; use native GET for current availability. Stable external identity makes a separate Idempotency-Key unnecessary for binding. Do not automatically rebase revisions or repeat uncertain changes.
Versioned bounded queries
Lists use one-based page, pageSize 1–100 (default 10), offset at most 10000 and search at most 240 characters. Unlike legacy normalization, versioned invalid page bounds return 400. Configured request policy may tighten limits. Responses contain items/page/pageSize/totalCount; stable GUID tie breakers do not promise snapshot pagination.
Businesses supports native status/recordStatus/contactStatus/gstinStatus, location and bounded location groups, UTC created range and needsAttention. Contacts supports status/linkStatus/source, missingEmail/missingPhone, businessId/excludeBusinessId, UTC created range and needsAttention. Leads supports native status/archive/current/inactive, pipeline/stage/list/owner/business/contact/source/origin and activity-user filters. Use the emitted query schema for exact field names and the resource sort allowlist. From is inclusive, Until exclusive; dates are UTC ISO 8601. No arbitrary expression or unrestricted export is accepted.
Versioned responses carry X-Request-ID and no-store, retaining X-Correlation-Id. Wrong-workspace native IDs return 404; source/management access can return 403. Existing error families above remain distinct. Durable Customers file workflows expose their existing batch/job lifecycle. Permanent deletion stays human-assessed; explicit child, relationship and native Calendar retirement commands preserve their native protections.