> 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.

# Create Grant Approval

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

Initiates the approval process for a new grant.


Reference: https://developers.cash.app/afterpay/api-reference/reference/grants-afterpay/start-grant-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` (string, optional, default: application/json)

### Body (application/json)

This endpoint expects a GrantApprovalRequest.

- `grants` (list of GrantApprovalType, required) — Grant type for approval (only single grant is supported)
- `merchant` (GrantApprovalRequestMerchant, required)
- `consumer` (Consumer, optional) — Consumer details for the grant

## Response

### 200

OK

- `token` (string, required) — Token identifying this grant 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 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 Forbidden Error

| errorCode | Description | | --- | --- | | feature_not_enabled | On file payments are not enabled for this merchant. |

- `any`

### 415 Unsupported Media Type Error

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

- `any`

### 422 Unprocessable Entity Error

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

- `any`

## Types

### GrantApprovalType

Details about the grant to be created.

- `type` (enum, required) — Grant Type for approval.
  - Allowed values: `ON_FILE`
- `merchantReference` (string, optional, nullable) — A merchant-provided reference for the grant.

### GrantApprovalRequestMerchant

- `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)

## Examples

**Request**

```json
{
  "grants": [
    {
      "type": "ON_FILE"
    }
  ],
  "merchant": {
    "redirectConfirmUrl": "https://example.com/approval/confirm",
    "redirectCancelUrl": "https://example.com/approval/cancel"
  }
}
```

**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/grants/approvals"

payload = {
    "grants": [{ "type": "ON_FILE" }],
    "merchant": {
        "redirectConfirmUrl": "https://example.com/approval/confirm",
        "redirectCancelUrl": "https://example.com/approval/cancel"
    }
}
headers = {
    "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/grants/approvals';
const credentials = btoa("<username>:<password>");

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"grants":[{"type":"ON_FILE"}],"merchant":{"redirectConfirmUrl":"https://example.com/approval/confirm","redirectCancelUrl":"https://example.com/approval/cancel"}}'
};

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/grants/approvals"

	payload := strings.NewReader("{\n  \"grants\": [\n    {\n      \"type\": \"ON_FILE\"\n    }\n  ],\n  \"merchant\": {\n    \"redirectConfirmUrl\": \"https://example.com/approval/confirm\",\n    \"redirectCancelUrl\": \"https://example.com/approval/cancel\"\n  }\n}")

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

	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/grants/approvals")

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

request = Net::HTTP::Post.new(url)
request.basic_auth("<username>", "<password>")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"grants\": [\n    {\n      \"type\": \"ON_FILE\"\n    }\n  ],\n  \"merchant\": {\n    \"redirectConfirmUrl\": \"https://example.com/approval/confirm\",\n    \"redirectCancelUrl\": \"https://example.com/approval/cancel\"\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/grants/approvals")
  .basicAuth("<username>", "<password>")
  .header("Content-Type", "application/json")
  .body("{\n  \"grants\": [\n    {\n      \"type\": \"ON_FILE\"\n    }\n  ],\n  \"merchant\": {\n    \"redirectConfirmUrl\": \"https://example.com/approval/confirm\",\n    \"redirectCancelUrl\": \"https://example.com/approval/cancel\"\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/grants/approvals', [
  'body' => '{
  "grants": [
    {
      "type": "ON_FILE"
    }
  ],
  "merchant": {
    "redirectConfirmUrl": "https://example.com/approval/confirm",
    "redirectCancelUrl": "https://example.com/approval/cancel"
  }
}',
  'headers' => [
    '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/grants/approvals");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"grants\": [\n    {\n      \"type\": \"ON_FILE\"\n    }\n  ],\n  \"merchant\": {\n    \"redirectConfirmUrl\": \"https://example.com/approval/confirm\",\n    \"redirectCancelUrl\": \"https://example.com/approval/cancel\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

let headers = [
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = [
  "grants": [["type": "ON_FILE"]],
  "merchant": [
    "redirectConfirmUrl": "https://example.com/approval/confirm",
    "redirectCancelUrl": "https://example.com/approval/cancel"
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://global-api-sandbox.afterpay.com/v2/grants/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()
```