> For the complete documentation index, see [llms.txt](https://documentation.themembers.dev.br/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.themembers.dev.br/api-gerenciamento-de-usuarios/referencia-da-api/assinaturas.md).

# Assinaturas

## Criação de assinatura para um usuário

<mark style="color:blue;">`POST`</mark> `URL_BASE/users/create/user-subscription/{token_do_desenvolvedor}/{token_da_plataforma}`

#### Request Body

| Name                                          | Type   | Description                                            |
| --------------------------------------------- | ------ | ------------------------------------------------------ |
| product\_id<mark style="color:red;">\*</mark> | String | Id do produto                                          |
| user\_id                                      | String | Id do usuário (uuid)                                   |
| payment\_last\_date                           | Date   | Data do último pagamento - formato: Y-m-d H:i:s        |
| expiration\_date                              | Date   | Data de expiração da assinatura - formato: Y-m-d H:i:s |
| reference\_id                                 | String | Id referência                                          |

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

```json
{
    "check": true,
    "data": {
        "user_subscription": {
            "id": 1234,
            "tenant_id": 4451,
            "active": 1,
            "status": "active",
            "user_id": "550e8400-e29b-41d4-a716-446655440000",
            "package_id": "660e8400-e29b-41d4-a716-446655440001",
            "payment_last_date": "2025-06-18T10:30:00.000000Z",
            "expiration_date": "2026-06-18T00:00:00.000000Z",
            "accession_date": "2025-06-18T10:30:00.000000Z",
            "created_at": "2025-06-18T10:30:00.000000Z",
            "updated_at": "2025-06-18T10:30:00.000000Z"
        }
    },
    "errors": [],
    "messages": ["Subscription criada com sucesso!"]
}
```

{% endtab %}
{% endtabs %}

## Editar de assinatura para um usuário

<mark style="color:orange;">`PUT`</mark> `URL_BASE/users/update/user-subscription/{token_do_desenvolvedor}/{token_da_plataforma}`

#### Request Body

| Name                                          | Type   | Description                                            |
| --------------------------------------------- | ------ | ------------------------------------------------------ |
| product\_id<mark style="color:red;">\*</mark> | String | Id do produto                                          |
| user\_id<mark style="color:red;">\*</mark>    | String | Id do usuário (uuid)                                   |
| payment\_last\_date                           | Date   | Data do último pagamento - formato: Y-m-d H:i:s        |
| expiration\_date                              | Date   | Data de expiração da assinatura - formato: Y-m-d H:i:s |

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

```json
{
    "check": true,
    "data": [],
    "errors": [],
    "messages": ["Assinatura atualizada com sucesso!"]
}
```

{% endtab %}
{% endtabs %}

## Ativar a assinatura para um usuário

<mark style="color:orange;">`PUT`</mark> `URL_BASE/users/update/active-user-subscription/{token_do_desenvolvedor}/{token_da_plataforma}`

#### Request Body

| Name                                          | Type   | Description          |
| --------------------------------------------- | ------ | -------------------- |
| product\_id<mark style="color:red;">\*</mark> | String | Id do produto        |
| user\_id<mark style="color:red;">\*</mark>    | String | Id do usuário (uuid) |

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

```json
{
    "check": true,
    "data": [],
    "errors": [],
    "messages": ["Inscrição ativada com sucesso!"]
}
```

{% endtab %}
{% endtabs %}

## Desativar a assinatura para um usuário

<mark style="color:orange;">`PUT`</mark> `URL_BASE/users/update/disable-user-subscription/{token_do_desenvolvedor}/{token_da_plataforma}`

#### Request Body

| Name                                          | Type   | Description          |
| --------------------------------------------- | ------ | -------------------- |
| product\_id<mark style="color:red;">\*</mark> | String | Id do produto        |
| user\_id<mark style="color:red;">\*</mark>    | String | Id do usuário (uuid) |

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

```json
{
    "check": true,
    "data": [],
    "errors": [],
    "messages": ["Inscrição inativa com sucesso!"]
}
```

{% endtab %}
{% endtabs %}

## Deletar assinatura por id referência

<mark style="color:red;">`DELETE`</mark> `URL_BASE/users/destroy-subscription-reference-id/{reference_id}/{product_id}/{token_do_desenvolvedor}/{token_da_plataforma}`

Após a exclusão do usuário a operação não poderá ser revertida.

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

```json
{
    "check": true,
    "data": [],
    "errors": [],
    "messages": ["Subscription apagada"]
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Deletar assinatura por id do usuário

<mark style="color:red;">`DELETE`</mark> `URL_BASE/users/destroy-subscription-user-id/{user_id}/{product_id}/{token_do_desenvolvedor}/{token_da_plataforma}`

Após a exclusão do usuário a operação não poderá ser revertida.

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

```json
{
    "check": true,
    "data": [],
    "errors": [],
    "messages": ["Subscription apagada"]
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}
