Approve a revenue contract

Operation ID: approveRevenueContract

Group: Accounting › Revenue Contracts

Open in the interactive reference

POST /accounting/revenue-contracts/{id}/approve

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Approves a revenue contract.

POST accounting/revenue-contracts/7c41e9a2-58d6-4b03-9f17-2ae6c085d3b4/approve

The body is empty and so is the response. Read the contract back with GET accounting/revenue-contracts/{id} to see its approved state.

This is the first write route on revenue contracts — until now the api could read them and nothing more, so a contract raised by an approved order could only be approved through the UI.

Approving a contract is what releases it for revenue recognition. An approved contract's revenue plan lines become postable; an unapproved one recognises nothing. The call re-syncs the contract's business object and writes the activity trail on both the contract and the sales order it came from.

The sales order must be approved first. A contract recognises revenue for the obligations its order fixes, so approving it ahead of the order is refused with SALES_ORDER_NOT_APPROVED and nothing is written. Approve the order with POST accounting/sales-orders/{id}/approve, then call this. Approving an order does not approve its contract — the two are deliberately separate calls.

Approving is idempotent. A contract that is already approved returns success and changes nothing; the REVENUE_CONTRACT_ALREADY_APPROVED information diagnostic is how a caller tells that case from a fresh approval (REVENUE_CONTRACT_APPROVED), so a retry after a timeout is safe.

Approving an id that does not exist is NOT_FOUND, not a silent success. The call runs in a transaction, so a failure part-way leaves the contract untouched.

Parameters

Name In Type Required Description
Api-Version header string · v1 yes The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version v1.
Idempotency-Key header string no An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with 400 IDEMPOTENCY_NOT_SUPPORTED rather than silently ignored.
id path string yes Id (a UUID) of the revenue contract to approve; bound from the :id path segment. Example: "7c41e9a2-58d6-4b03-9f17-2ae6c085d3b4".

Response

200 Success

{
  "data": {},
  "diagnostics": [
    {
      "code": "REVENUE_CONTRACT_APPROVED",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": {
        "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
      }
    }
  ]
}

Response headers

Errors

Code Status
NOT_FOUND 400
SALES_ORDER_NOT_APPROVED 400
NOT_APPROVABLE 400
IDEMPOTENCY_KEY_CONFLICT 409
IDEMPOTENCY_PAYLOAD_MISMATCH 422

Advisories

Warnings and information a successful response can carry under diagnostics:

Statuses