Set the invoice that sold an order
curl --request POST \ --url https://example.com/api/v1/orders/example/source-invoice \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "invoiceId": "example" }'Makes an uncancelled invoice of the order’s company the order’s source invoice and gives back the hours or tokens the order lost when its previous source was cancelled or deleted. Only an order with no source invoice takes one, and the invoice must sell no other order. Requires the orders.edit and invoices.manage permissions, an order the caller reaches and an invoice within their invoice scope. A refusal carries a reason: ORDER_NOT_FOUND and INVOICE_NOT_FOUND (404); ORDER_HAS_SOURCE_INVOICE and INVOICE_SELLS_ANOTHER_ORDER (409); ORDER_CLIENT_MISMATCH and INVOICE_NOT_LINKABLE (422).
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Resource identifier (CUID2).
Resource identifier (CUID2).
Request Body
Section titled “Request Body”object
An uncancelled invoice of the order’s company that sells no other order and, for an order counted in hours, sells hours (a line of a service or package that defines hours, or a line without a service). It becomes the order’s source invoice and gives back the hours or tokens the order lost when its previous source was cancelled or deleted.
Example generated
{ "invoiceId": "example"}Responses
Section titled “Responses”The invoice that now sources the order and what the order got back.
object
The invoice that now sources the order and what the order got back.
object
Hours the order got back; 0 when it had lost none.
Tokens the order got back; 0 when it had lost none.
Example generated
{ "data": { "invoiceId": "example", "invoiceNumber": "example", "orderId": "example", "restoredHours": 1, "restoredTokens": 1 }}Validation error. Parse failures include field paths and expectations.
Validation error with safe field paths and expected values; submitted values are never returned.
object
object
Stable machine-readable error code.
object
Human-readable error message.
HTTP status code, mirrored in the body.
Example
{ "error": { "code": "UNAUTHORIZED" }}Unauthorized.
Standard error envelope.
object
object
Stable machine-readable error code.
Human-readable error message.
HTTP status code, mirrored in the body.
Example
{ "error": { "code": "UNAUTHORIZED" }}Forbidden.
Standard error envelope.
object
object
Stable machine-readable error code.
Human-readable error message.
HTTP status code, mirrored in the body.
Example
{ "error": { "code": "UNAUTHORIZED" }}The order or the invoice does not exist or is out of reach.
Standard error envelope.
object
object
Stable machine-readable error code.
Human-readable error message.
HTTP status code, mirrored in the body.
Example
{ "error": { "code": "UNAUTHORIZED" }}The order already has a source invoice (ORDER_HAS_SOURCE_INVOICE) or the invoice sells another order (INVOICE_SELLS_ANOTHER_ORDER).
Standard error envelope.
object
object
Stable machine-readable error code.
Human-readable error message.
HTTP status code, mirrored in the body.
Example
{ "error": { "code": "UNAUTHORIZED" }}The invoice is of another company (ORDER_CLIENT_MISMATCH) or cannot be linked (INVOICE_NOT_LINKABLE).
Standard error envelope.
object
object
Stable machine-readable error code.
Human-readable error message.
HTTP status code, mirrored in the body.
Example
{ "error": { "code": "UNAUTHORIZED" }}Rate limit exceeded. Wait for Retry-After before retrying.
Standard error envelope.
object
object
Stable machine-readable error code.
Human-readable error message.
HTTP status code, mirrored in the body.
Example
{ "error": { "code": "UNAUTHORIZED" }}Headers
Section titled “Headers”Maximum requests in the current quota window.
Quota policy in requests and window seconds, for example 60;w=60.
Requests left in this quota window (zero when blocked).
Seconds until the current quota window resets, when available from the rate-limit store.
Seconds until another request may be attempted.
Chelsea is operated by Arepa Labs LLC