Provisioning from a CRM
When a deal closes in your CRM, one call to POST /api/v2/provision sets up everything Paid needs to bill it: the customer, an optional contact, the products on the deal, and the order with its lines. Each record carries the ID it has in your CRM, so you can send the same deal again when it changes, and Paid updates the records it already has instead of creating new ones.
Use this endpoint when you build your own integration between a CRM or quoting tool and Paid.
Prerequisites
- A Paid API key with the
write:billingscope. Full-access keys have it. - A stable ID in your CRM for the account, the deal, each line item, and each product. Paid calls these
externalId.
How Paid matches records
Paid never asks for its own IDs in a provision request. It finds each record by the externalId you send, and creates the record if none exists.
An order line is one product on the order, with its prices. An attribute is one priced part of a product, such as a monthly platform fee or a usage charge.
Make a provision request
This request provisions a customer with one order line: a platform fee of $499.00 per month, billed in advance.
The response gives the Paid ID of each record and says whether it was created or updated:
The order in this request is active, because order.status defaults to active, so Paid activates it and starts billing. To stage an order without billing it, set order.status to draft. When the deal closes, provision the order again with status set to active, or with status left out.
Create, update, or conflict
The status code tells you what happened to the order:
Treat both 200 and 201 as success. The customer, contact, and products are created or updated in both cases.
Paid does not change an active order through a provision request, because the order may already be invoiced. To change an active order, for example to add a product or change a quantity, use the amendments API. Amending orders explains what an amendment can change.
Retries and idempotency keys
Every request needs an idempotency-key header. The key lets you retry a request safely after a timeout or a network error: Paid runs a request once for each key. Build the key from the deal and its version, such as the deal ID plus its last-modified time. When the deal changes, the key changes too.
After PROVISION_OUTCOME_UNKNOWN, look up the order with List orders, filtered by its externalId, before you send the deal again with a new key.
If a request fails before Paid saves anything, for example with a 400 validation error, Paid does not store a response for its key. Fix the request and send it again with the same key.
Keys are scoped to your organization.
Amounts and discounts
All prices are whole numbers in minor currency units, such as cents for USD. 49900 is $499.00. Paid rejects decimal and negative prices.
To give a discount or a credit, add a separate order line with lineType set to CREDIT, and send its prices as positive amounts. Paid subtracts a credit line from the invoice. For example, a credit line with a monthly price of 10000 takes $100.00 off each monthly invoice until the line’s endDate.
Credit amounts in creditBenefits are numbers of credits, not money.
Choose a source
externalReference.source names the system that sends the provision request. Use standard for an integration you build yourself.
Where the external reference is stored
Paid stores the whole externalReference object on the order’s metadata, under the externalReference key. Put the IDs you need to trace an order back to your CRM in externalReference.metadata. For the request above, the order’s metadata contains:
Each provision request for the order replaces externalReference. Other keys in the order’s metadata stay as they are. You can read the metadata with Get order.