> For the complete documentation index, see [llms.txt](https://docs.biti.so/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.biti.so/subscriptions-1.md).

# subscriptions

Ask a customer to approve a recurring plan.

| Endpoint                                                                       | Purpose                          |
| ------------------------------------------------------------------------------ | -------------------------------- |
| [`POST /partner/v1/request-subscription`](#post-partnerv1request-subscription) | Request a subscription           |
| [`POST /partner/v1/subscription-status`](#post-partnerv1subscription-status)   | Get the status of a subscription |

## POST /partner/v1/request-subscription

**Request a subscription**

{% hint style="info" %}
Auth: send `client_id` and `client_secret` in the request body. Call it from your server only.
{% endhint %}

Ask a customer to approve a recurring charge for a plan. The answer holds the subscription, `created` (`false` when the same request already exists) and a `deeplink` that opens the approval screen in Biti.

The answer `data` holds `created` and `deeplink`, plus the subscription record.

**Errors:**

* Invalid client credentials

### Parameters

| Name            | Type    | Required | Description                                                                 |
| --------------- | ------- | -------- | --------------------------------------------------------------------------- |
| `client_id`     | string  | yes      | Your client ID.                                                             |
| `client_secret` | string  | yes      | Your client secret. Server only.                                            |
| `phone`         | string  | yes      | Customer phone number.                                                      |
| `plan_name`     | string  | yes      | Name of the plan.                                                           |
| `amount`        | number  | yes      | Amount per period.                                                          |
| `currency`      | string  | yes      | Currency code.                                                              |
| `trial_days`    | integer | no       | Free trial days.                                                            |
| `reference`     | string  | no       | Your unique id for the subscription. Use it later in `subscription-status`. |

### Request

{% tabs %}
{% tab title="curl" %}

```bash
curl -X POST "https://api.biti.so/partner/v1/request-subscription" \
  -H "Content-Type: application/json" \
  -d '{
  "client_id": "YOUR_CLIENT_ID",
  "client_secret": "YOUR_CLIENT_SECRET",
  "phone": "+252615123456",
  "plan_name": "Diyaar Plus",
  "amount": 9.99,
  "currency": "USD",
  "trial_days": 7,
  "reference": "SUB-C1009"
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.biti.so/partner/v1/request-subscription"
headers = {
    "Content-Type": "application/json",
}
payload = {
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "phone": "+252615123456",
    "plan_name": "Diyaar Plus",
    "amount": 9.99,
    "currency": "USD",
    "trial_days": 7,
    "reference": "SUB-C1009",
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const response = await fetch("https://api.biti.so/partner/v1/request-subscription", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "phone": "+252615123456",
    "plan_name": "Diyaar Plus",
    "amount": 9.99,
    "currency": "USD",
    "trial_days": 7,
    "reference": "SUB-C1009"
  }),
});
console.log(await response.json());
```

{% endtab %}
{% endtabs %}

### Response

```json
{
  "success": true,
  "message": "Subscription requested",
  "data": {
    "subscription": "SUB-00031",
    "reference": "PLAN-C1009",
    "status": "pending",
    "plan_name": "Diyaar Plus",
    "amount": 4.99,
    "currency": "USD",
    "interval": "monthly",
    "trial_ends_on": null,
    "next_charge_on": null,
    "ends_on": null,
    "paid_total": 0,
    "created": true,
    "deeplink": "biti://subscriptions/SUB-00031"
  }
}
```

## POST /partner/v1/subscription-status

**Get the status of a subscription**

{% hint style="info" %}
Auth: send `client_id` and `client_secret` in the request body. Call it from your server only.
{% endhint %}

Return the subscription that you created with `reference`.

**Errors:**

* Invalid client credentials
* Unknown subscription

### Parameters

| Name            | Type   | Required | Description                                         |
| --------------- | ------ | -------- | --------------------------------------------------- |
| `client_id`     | string | yes      | Your client ID.                                     |
| `client_secret` | string | yes      | Your client secret. Server only.                    |
| `reference`     | string | yes      | The `reference` you sent to `request-subscription`. |

### Request

{% tabs %}
{% tab title="curl" %}

```bash
curl -X POST "https://api.biti.so/partner/v1/subscription-status" \
  -H "Content-Type: application/json" \
  -d '{
  "client_id": "YOUR_CLIENT_ID",
  "client_secret": "YOUR_CLIENT_SECRET",
  "reference": "SUB-C1009"
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.biti.so/partner/v1/subscription-status"
headers = {
    "Content-Type": "application/json",
}
payload = {
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "reference": "SUB-C1009",
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const response = await fetch("https://api.biti.so/partner/v1/subscription-status", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "reference": "SUB-C1009"
  }),
});
console.log(await response.json());
```

{% endtab %}
{% endtabs %}

### Response

```json
{
  "success": true,
  "message": "",
  "data": {
    "subscription": "SUB-00031",
    "reference": "PLAN-C1009",
    "status": "active",
    "plan_name": "Diyaar Plus",
    "amount": 4.99,
    "currency": "USD",
    "interval": "monthly",
    "next_charge_on": "2026-12-18",
    "paid_total": 4.99
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.biti.so/subscriptions-1.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
