# Create an email billing

At the moment Cryptopay offers a system that allows for the creation and management of email billing exclusively through the API. Remember, that in a merchant's account, the email billing items are viewable without the capacity to make edits.

Let's [create a subscription](https://reference.cryptopay.me/#tag/Subscriptions/operation/subscriptions.create):

{% code overflow="wrap" fullWidth="false" %}

```bash
curl -X POST \
https://business-sandbox.cryptopay.me/api/subscriptions \
-H 'Authorization: HMAC ***' \
-H 'Content-Type: application/json' \
-H 'Date: Tue, 19 Mar 2019 10:11:40 GMT' \
-d '{"custom_id":"209584732", "name":"subscriptionName", "amount":"10", "currency":"EUR", "period":"month", "period_quantity":"1", "starts_at":"2023-08-25T15:53:02+00:00", "payer_email":"payer_email@email.com", "payer_name":"John Doe", "product_name":"Product name", "product_description":"Product description", "success_redirect_url":"https://successRedirectUrl.me/", "unsuccess_redirect_url":"https://unsuccessRedirectUrl.me/"}'
```

{% endcode %}

Let us go through the parameters we used in our request above:

* `custom_id` - we recommend you to specify a certain reference by which you associate your customer with the payment
* `name` - descriptive name for the subscription.
* `amount` - subscription price.
* `currency` - the currency of payment, i.e. the currency into which the cryptocurrency received will be converted and in which the merchant will be credited to the balance&#x20;
* `period` - periodicity of the subscription. Can be one of the following:
  * `day`
  * `week`
  * `month`&#x20;
  * `year`&#x20;
* `period_quantity` - number describing the jumps in periodicity (e.g., 2 for every two weeks).
* `starts_at` - date before which the first payment should be made. Аfter this date, the subscription will be cancelled.
* `payer_email` - email of the subscribing user.
* `payer_name` - name of the payer.
* `product_name` - name of the product.
* `product_description` - description of the product.
* `success_redirect_url` - URL for successful payment redirection.
* `unsuccess_redirect_url` - URL for unsuccessful payment redirection.

You will receive all that information back with status of the subscription and its id

{% code overflow="wrap" %}

```json
{
    "data": {
        "id": "8b0c6e70-16ba-4b97-87ea-378de1e04ad5",
        "status": "active",
        "custom_id": "209584732",
        "name": "subscriptionName",
        "amount": "10.0",
        "currency": "EUR",
        "period": "month",
        "period_quantity": 1,
        "current_period_starts_at": "2023-08-10T15:53:02+00:00",
        "current_period_ends_at": "2023-08-25T15:53:02+00:00",
        "current_period_paid": false,
        "payer_email": "payer_email@email.com",
        "payer_name": "John Doe",
        "product_name": "Product name",
        "product_description": "Product description",
        "success_redirect_url": "https://successRedirectUrl.me/",
        "unsuccess_redirect_url": "https://unsuccessRedirectUrl.me/",
        "created_at": "2023-08-10T15:53:02+00:00",
        "cancelled_at": null
    }
}
```

{% endcode %}

{% hint style="info" %}
It's crucial to note that the minimum acceptable date for the `starts_at` field is 3 days from the moment of the request creation, considering the current time. Additionally, from the moment of the request until the `starts_at` date, the subscription will be in an active status. It is assumed that during this period, the subscribing customer will have access to the designated product.
{% endhint %}

Upon successful subscription creation, you gain control over various management aspects:

* List of subscriptions: Retrieve a list of all project subscriptions using [specific API endpoint](https://reference.cryptopay.me/#tag/Subscriptions/operation/subscriptions.list).
* Individual subscription: Fetch a subscription by its ID using the [corresponding API endpoint](https://reference.cryptopay.me/#tag/Subscriptions/operation/subscriptions.retrieve).
* Retrieval by custom id: Acquire a subscription using its custom ID through [dedicated API endpoint](https://reference.cryptopay.me/#tag/Subscriptions/operation/subscriptions.retrieve-by-custom-id).
* Manual Subscription Cancellation: For cases requiring manual intervention, utilise [this API endpoint](https://reference.cryptopay.me/#tag/Subscriptions/operation/subscriptions.cancel) to cancel subscriptions as needed.

By leveraging these endpoints, you can manage subscriptions, track statuses, and ensure an optimal customer experience.

<br>
