# Subscriptions

## All Subscriptions

<mark style="color:blue;">`GET`</mark> `https://yoursite.mavenseed.com/api/v1/subscriptions`

Retrieve all subscriptions

#### Path Parameters

| Name | Type    | Description            |
| ---- | ------- | ---------------------- |
| page | integer | Results are paginated. |

#### Headers

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| Authorization | string | Auth token  |

{% tabs %}
{% tab title="200 Returns an array of members. Only the first 20 are returned. Passing the page param will paginate the results.
" %}

```javascript
[
    {
        "id": 12,
        "customer_id": null,
        "subscription_plan_id": null,
        "stripe_id": null,
        "expiration": null,
        "status": null,
        "created_at": "2019-09-16T13:40:50.336-04:00",
        "updated_at": "2019-09-16T13:40:50.336-04:00"
    },
    {
        "id": 18,
        "customer_id": 1956,
        "subscription_plan_id": 14,
        "stripe_id": "sub_G0EDCYMgIpWTS0",
        "expiration": "2019-11-16T09:45:59.000-05:00",
        "status": "active",
        "created_at": "2019-10-16T10:45:27.077-04:00",
        "updated_at": "2019-10-16T11:02:19.573-04:00"
    }
]
```

{% endtab %}
{% endtabs %}

## Show Subscription

<mark style="color:blue;">`GET`</mark> `https://yoursite.mavenseed.com/api/v1/subscriptions/:id`

Retrieve a single subscription

#### Headers

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| Authorization | string | Auth token  |

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

```ruby
{
    "id": 12,
    "customer_id": null,
    "subscription_plan_id": null,
    "stripe_id": null,
    "expiration": null,
    "status": null,
    "created_at": "2019-09-16T13:40:50.336-04:00",
    "updated_at": "2019-09-16T13:40:50.336-04:00"
}
```

{% endtab %}

{% tab title="404 " %}

```ruby
null
```

{% endtab %}
{% endtabs %}

## Create Subscription

<mark style="color:green;">`POST`</mark> `https://yoursite.mavenseed.com/api/v1/subscriptions`

Create a subscription.

#### Headers

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| Authorization | string | Auth Token  |

#### Request Body

| Name                   | Type    | Description                                                  |
| ---------------------- | ------- | ------------------------------------------------------------ |
| customer\_id           | integer | ID of customer to attach subscription to                     |
| subscription\_plan\_id | integer | ID of subscription plan for customoer                        |
| stripe\_id             | string  | Stripe subscription id                                       |
| expiration             | string  | Expiration of subscription in datetime format                |
| status                 | integer | 0 - active, 1 - past\_due, 2- canceled, 3 - unpaid, 4 - free |

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

```ruby
{
    "id": 12,
    "customer_id": null,
    "subscription_plan_id": null,
    "stripe_id": null,
    "expiration": null,
    "status": null,
    "created_at": "2019-09-16T13:40:50.336-04:00",
    "updated_at": "2019-09-16T13:40:50.336-04:00"
}
```

{% endtab %}
{% endtabs %}

## Update Subscription

<mark style="color:purple;">`PATCH`</mark> `https://yoursite.mavenseed.com/api/v1/subscriptions/:id`

Update a single subscription. All of the above properties in create subscription are valid.

#### Headers

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| Authorization | string | Auth token  |

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

```ruby
{
    "id": 12,
    "customer_id": null,
    "subscription_plan_id": null,
    "stripe_id": null,
    "expiration": null,
    "status": null,
    "created_at": "2019-09-16T13:40:50.336-04:00",
    "updated_at": "2019-09-16T13:40:50.336-04:00"
}
```

{% endtab %}
{% endtabs %}

## Delete a Subscription

<mark style="color:red;">`DELETE`</mark> `https://yoursite.mavenseed.com/api/v1/subscriptions/:id`

Delete a subscription.

#### Headers

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| Authorization | string | Auth token. |

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

```
```

{% endtab %}
{% endtabs %}
