# Subscription

{% hint style="info" %}
How to create a new Stripe subscription for the logged user
{% endhint %}

Calling this API will immediately charge the user (or after the trial has ended). Based on the subscription charge period, it will continue to charge the user.

For the subscription lifecycle please refer to [Stripe documentation](https://stripe.com/docs/billing/lifecycle)

{% tabs %}
{% tab title="Request" %}
`POST https://mburger.cloud/api/subscriptions`

```bash
curl https://mburger.cloud/api/subscriptions
-X POST
-H "Accept: application/json" 
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
-H "Authorization: Bearer <JWT>"
-d '<data>' 
```

#### &#x20;Parameters

| Name           | Type   | Required | Description                                                                                                                      |
| -------------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
| subscription   | string | Yes      | Subscription identifier chosen on Stripe dashboard.                                                                              |
| token          | string | No       | Source token provided by the Stripe SDK, it is not required if the user is already a customer and wants to use the default card. |
| discount\_code | string | No       | Identifier of discount code.                                                                                                     |
| trial\_days    | int    | No       | Number of days before the first charge of the subscription.                                                                      |
| quantity       | int    | No       | Quantity of subscriptions you'll need to subscribe; generally 1 or no data.                                                      |
| meta           | JSON   | No       | Additional data to save for the subscription.                                                                                    |
| {% endtab %}   |        |          |                                                                                                                                  |

{% tab title="Response" %}
When successful, a HTTP 200 and JSON like this is returned:

```bash
{
  "status_code": 0
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mburger.cloud/api-docs-1/integrations-extensions/stripe/subscription.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
