For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
HomeGuidesAPI Reference
HomeGuidesAPI Reference
  • Reference
    • Introduction
      • POSTCreate Billing Agreement
      • POSTCreate Billing Agreement Alias
      • POSTStart Billing Agreement Approval Process
      • PUTCancel Billing Agreement (Alternative)
      • POSTRetrieve Billing Agreement Offers
      • POSTRetrieve Billing Agreement
      • POSTStart Billing Agreement Link Flow
      • GETGet Billing Agreement Details
      • DELCancel Billing Agreement
      • POSTCapture Full Recurring Payment
      • POSTAuthorize Recurring Payment
LogoLogo
ReferenceBilling Agreements (Deprecated)

Create Billing Agreement

POST
/v2/billing-agreements
POST
/v2/billing-agreements
$curl -X POST https://global-api-sandbox.afterpay.com/v2/billing-agreements \
> -H "User-Agent: User-Agent" \
> -H "Content-Type: application/json" \
> -u "<username>:<password>" \
> -d '{
> "token": "005.2fkv5o963b132z8ppa34srlh60987y87d55re237wsg9tr4q2"
>}'
1{
2 "token": "005.2fkv5o963b132z8ppa34srlh60987y87d55re237wsg9tr4q2",
3 "type": "BILLING",
4 "status": "ACTIVE",
5 "created": "2024-03-04T12:00:00Z",
6 "merchantReference": "merchant_ref_123",
7 "cancelled": "2024-03-05T12:00:00Z",
8 "expires": "2025-03-04T12:00:00Z",
9 "events": [
10 {
11 "type": "CAPTURE",
12 "created": "2024-03-04T10:30:00Z",
13 "amount": {
14 "amount": "100.00",
15 "currency": "AUD"
16 },
17 "status": "APPROVED",
18 "merchantReference": "merchant-event-ref-789",
19 "orderId": 123
20 }
21 ],
22 "requestId": "req_abc123def456",
23 "consumerReference": "cust_12345",
24 "email": "j***@e***.com"
25}
Creates a new billing agreement from an order token. *Deprecated. For new integrations, see [Grants](https://afterpay.docs.buildwithfern.com/afterpay-online-developer/api-reference/reference/grants/start-grant-approval).*
Was this page helpful?
Previous

Create Billing Agreement Alias

Next
Built with

Creates a new billing agreement from an order token.

Deprecated. For new integrations, see Grants.

Authentication

AuthorizationBasic

Basic authentication of the form Basic <base64(username:password)>.

Headers

User-AgentstringRequired
AcceptstringOptionalDefaults to application/json

Request

The request containing the details needed to create a billing agreement
tokenstringRequired
The token returned from the create approval request.
requestIdstringOptional<=64 characters
A unique request ID, required for idempotent retries. It is recommended that the merchant generate a UUID for each unique request.
merchantReferencestringOptional

The reference order id that this payment corresponds to in the merchant’s system. Note: Providing a new value will update any value previously set in the Create Checkout request.

Response

Billing agreement created successfully
tokenstring
Unique token identifying the agreement
typeenum
Type of agreement
Allowed values:
statusenum
Current status of the agreement
Allowed values:
createdstringformat: "date-time"
Timestamp when the agreement was created
merchantReferencestring or null
Merchant's reference for this agreement
cancelledstringformat: "date-time"
If present, indicates when the agreement was cancelled
expiresstringformat: "date-time"
If present, indicates when the agreement's status will become EXPIRED, preventing a client from using it to create payments
eventslist of objects
List of events associated with this agreement
requestIdstring or null
Unique identifier for the request
consumerReferencestring or null
Reference identifier for the consumer
emailstring or null
Masked email address of the consumer

Errors

403
Forbidden Error
412
Precondition Failed Error
415
Unsupported Media Type Error