> This page is for Afterpay.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.cash.app/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.cash.app/_mcp/server.

# Start Billing Agreement Approval Process

POST https://global-api-sandbox.afterpay.com/v2/billing-agreements/approvals
Content-Type: application/json

Initiates the approval process for a new billing agreement.

*Deprecated. For new integrations, see [Grants](https://afterpay.docs.buildwithfern.com/afterpay-online-developer/api-reference/reference/grants/start-grant-approval).*

Reference: https://developers.cash.app/afterpay/api-reference/reference/billing-agreements-deprecated/start-billing-agreement-approval

## Authentication

- `Authorization` header (basic auth, required) — Basic authentication of the form `Basic <base64(username:password)>`.

## Servers

- `https://global-api-sandbox.afterpay.com` (Sandbox, default)
- `https://global-api.afterpay.com` (Production)

## Request

### Headers

- `Accept` ("application/json", required)

### Body (application/json)

This endpoint expects an object.

- `merchant` (BillingAgreementApprovalRequestMerchant, required)
- `consumer` (Consumer, optional) — Consumer details for the billing agreement
- `merchantReference` (string, optional) — Merchant's unique reference for this billing agreement
- `agreements` (list of AgreementApproval, optional) — Agreement type for approval (only single agreement is supported)

## Response

### 200

The consumer approved the billing agreement

- `token` (string, required) — Token identifying this billing agreement approval request
- `expires` (datetime, required) — When this approval request expires
- `redirectCheckoutUrl` (string, required) — URL where the consumer should be redirected to complete approval

## Errors

### 401 Start Billing Agreement Approval Request Unauthorized Error

Authentication failed or insufficient permissions. | errorCode | Description | | --- | --- | | unauthorized | The API credentials are invalid or missing. | | insufficient_permissions | The merchant lacks the required 'merchant_api_v2/initiate' permission. |

- `any`

### 403 Start Billing Agreement Approval Request Forbidden Error

| errorCode | Description | | --- | --- | | billing_agreement_not_authorised | Recurring payments are not enabled for this merchant. |

- `any`

### 415 Start Billing Agreement Approval Request Unsupported Media Type Error

Unsupported Media Type - Content-Type header is missing or invalid

- `any`

### 422 Start Billing Agreement Approval Request Unprocessable Entity Error

| errorCode | Description | | --- | --- | | invalid_object | One or more required fields in the request body were missing or invalid. |

- `any`

## Types

### BillingAgreementApprovalRequestMerchant

- `redirectConfirmUrl` (string, required)
- `redirectCancelUrl` (string, required)
- `popupOriginUrl` (string, optional) — This property is optional when a `redirectConfirmURL` is provided.
- `name` (string, optional) — The merchant name displayed in the Afterpay approval flow.

### Consumer

The consumer data model is used for gathering essential user information. It captures details such as the individual's first name, represented by `givenNames`, and their last name, captured under `surname`. In addition, it stores the user's contact number under `phoneNumber` and their email address under `email`. These fields collectively provide contact and identification details for a user.

- `email` (string, required)
- `givenNames` (string, optional) — The consumer's first name
- `surname` (string, optional) — The consumer's last name
- `phoneNumber` (string, optional)

### AgreementApproval

Details about the agreement to be created.

- `type` ("BILLING", required) — Agreement Type for approval.
- `merchantReference` (string, optional) — A merchant-provided reference for the agreement.

## Examples

**Request**

```json
{
  "merchant": {
    "redirectConfirmUrl": "http://example.com/confirm",
    "redirectCancelUrl": "http://example.com/cancel"
  },
  "consumer": {
    "email": "test@example.com",
    "givenNames": "Joe",
    "surname": "Customer",
    "phoneNumber": "11111111111"
  },
  "merchantReference": "merchant-order-12345",
  "agreements": [
    {
      "type": "BILLING",
      "merchantReference": "merchant-order-12345"
    }
  ]
}
```

**Response**

```json
{
  "token": "ba_approval_xyz789abc123",
  "expires": "2024-03-05T22:13:45Z",
  "redirectCheckoutUrl": "https://portal.afterpay.com/us/checkout/ba-approval?token=ba_approval_xyz789abc123"
}
```

**SDK Code**

```python
import requests

url = "https://global-api-sandbox.afterpay.com/v2/billing-agreements/approvals"

payload = {
    "merchant": {
        "redirectConfirmUrl": "http://example.com/confirm",
        "redirectCancelUrl": "http://example.com/cancel"
    },
    "consumer": {
        "email": "test@example.com",
        "givenNames": "Joe",
        "surname": "Customer",
        "phoneNumber": "11111111111"
    },
    "merchantReference": "merchant-order-12345",
    "agreements": [
        {
            "type": "BILLING",
            "merchantReference": "merchant-order-12345"
        }
    ]
}
headers = {
    "Accept": "application/json"
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, auth=("<username>", "<password>"))

print(response.json())
```

```javascript
const url = 'https://global-api-sandbox.afterpay.com/v2/billing-agreements/approvals';
const credentials = btoa("<username>:<password>");

const options = {
  method: 'POST',
  headers: {
    Accept: 'application/json',
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"merchant":{"redirectConfirmUrl":"http://example.com/confirm","redirectCancelUrl":"http://example.com/cancel"},"consumer":{"email":"test@example.com","givenNames":"Joe","surname":"Customer","phoneNumber":"11111111111"},"merchantReference":"merchant-order-12345","agreements":[{"type":"BILLING","merchantReference":"merchant-order-12345"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://global-api-sandbox.afterpay.com/v2/billing-agreements/approvals"

	payload := strings.NewReader("{\n  \"merchant\": {\n    \"redirectConfirmUrl\": \"http://example.com/confirm\",\n    \"redirectCancelUrl\": \"http://example.com/cancel\"\n  },\n  \"consumer\": {\n    \"email\": \"test@example.com\",\n    \"givenNames\": \"Joe\",\n    \"surname\": \"Customer\",\n    \"phoneNumber\": \"11111111111\"\n  },\n  \"merchantReference\": \"merchant-order-12345\",\n  \"agreements\": [\n    {\n      \"type\": \"BILLING\",\n      \"merchantReference\": \"merchant-order-12345\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Accept", "application/json")
	req.SetBasicAuth("<username>", "<password>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://global-api-sandbox.afterpay.com/v2/billing-agreements/approvals")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/json'
request.basic_auth("<username>", "<password>")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"merchant\": {\n    \"redirectConfirmUrl\": \"http://example.com/confirm\",\n    \"redirectCancelUrl\": \"http://example.com/cancel\"\n  },\n  \"consumer\": {\n    \"email\": \"test@example.com\",\n    \"givenNames\": \"Joe\",\n    \"surname\": \"Customer\",\n    \"phoneNumber\": \"11111111111\"\n  },\n  \"merchantReference\": \"merchant-order-12345\",\n  \"agreements\": [\n    {\n      \"type\": \"BILLING\",\n      \"merchantReference\": \"merchant-order-12345\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://global-api-sandbox.afterpay.com/v2/billing-agreements/approvals")
  .header("Accept", "application/json")
  .basicAuth("<username>", "<password>")
  .header("Content-Type", "application/json")
  .body("{\n  \"merchant\": {\n    \"redirectConfirmUrl\": \"http://example.com/confirm\",\n    \"redirectCancelUrl\": \"http://example.com/cancel\"\n  },\n  \"consumer\": {\n    \"email\": \"test@example.com\",\n    \"givenNames\": \"Joe\",\n    \"surname\": \"Customer\",\n    \"phoneNumber\": \"11111111111\"\n  },\n  \"merchantReference\": \"merchant-order-12345\",\n  \"agreements\": [\n    {\n      \"type\": \"BILLING\",\n      \"merchantReference\": \"merchant-order-12345\"\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://global-api-sandbox.afterpay.com/v2/billing-agreements/approvals', [
  'body' => '{
  "merchant": {
    "redirectConfirmUrl": "http://example.com/confirm",
    "redirectCancelUrl": "http://example.com/cancel"
  },
  "consumer": {
    "email": "test@example.com",
    "givenNames": "Joe",
    "surname": "Customer",
    "phoneNumber": "11111111111"
  },
  "merchantReference": "merchant-order-12345",
  "agreements": [
    {
      "type": "BILLING",
      "merchantReference": "merchant-order-12345"
    }
  ]
}',
  'headers' => [
    'Accept' => 'application/json',
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<username>', '<password>'],
]);

echo $response->getBody();
```

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://global-api-sandbox.afterpay.com/v2/billing-agreements/approvals");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"merchant\": {\n    \"redirectConfirmUrl\": \"http://example.com/confirm\",\n    \"redirectCancelUrl\": \"http://example.com/cancel\"\n  },\n  \"consumer\": {\n    \"email\": \"test@example.com\",\n    \"givenNames\": \"Joe\",\n    \"surname\": \"Customer\",\n    \"phoneNumber\": \"11111111111\"\n  },\n  \"merchantReference\": \"merchant-order-12345\",\n  \"agreements\": [\n    {\n      \"type\": \"BILLING\",\n      \"merchantReference\": \"merchant-order-12345\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<username>:<password>".utf8).base64EncodedString()

let headers = [
  "Accept": "application/json",
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = [
  "merchant": [
    "redirectConfirmUrl": "http://example.com/confirm",
    "redirectCancelUrl": "http://example.com/cancel"
  ],
  "consumer": [
    "email": "test@example.com",
    "givenNames": "Joe",
    "surname": "Customer",
    "phoneNumber": "11111111111"
  ],
  "merchantReference": "merchant-order-12345",
  "agreements": [
    [
      "type": "BILLING",
      "merchantReference": "merchant-order-12345"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://global-api-sandbox.afterpay.com/v2/billing-agreements/approvals")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```