> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chargefy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Discount

> Cria uma regra econômica de desconto.

Cria um `discount`. Para um cupom digitável pelo comprador, crie depois um
[`discount_code`](/api-reference/discount-codes/create) com `discount_id`.

## Autenticação

A API key da própria organização atua diretamente. A API key de plataforma exige o
header `Organization: <organization_id>` apontando para uma organização
conectada ativa.

## Attributes

<ParamField body="amount_off" type="integer">
  Valor fixo em centavos. Obrigatório quando `type=fixed`.
</ParamField>

<ParamField body="applies_to" type="object">
  Escopo do desconto. Use `products` com IDs `prod_*`; array vazio aplica a
  todos os produtos. Quando há produtos definidos, o abatimento é calculado
  somente sobre o subtotal das linhas elegíveis.
</ParamField>

<ParamField body="currency" type="string">
  Código ISO de 3 letras minúsculas. Obrigatório quando `type=fixed`.
</ParamField>

<ParamField body="duration" type="string" default="once">
  `once`, `forever` ou `repeating`.
</ParamField>

<ParamField body="duration_in_months" type="integer">
  Obrigatório quando `duration=repeating`.
</ParamField>

<ParamField body="expires_at" type="string">
  Data ISO 8601 de expiração.
</ParamField>

<ParamField body="max_redemptions" type="integer">
  Limite total de aplicações.
</ParamField>

<ParamField body="metadata" type="object">
  Objeto livre para correlação.
</ParamField>

<ParamField body="name" type="string" required>
  Nome do desconto.
</ParamField>

<ParamField body="percent_off_basis_points" type="integer">
  Percentual em basis points. Obrigatório quando `type=percentage`.
</ParamField>

<ParamField body="starts_at" type="string">
  Data ISO 8601 a partir da qual o desconto passa a valer.
</ParamField>

<ParamField body="type" type="string" required>
  `percentage` ou `fixed`.
</ParamField>

<RequestExample>
  ```bash percentage theme={}
  curl -X POST "https://api.chargefy.io/v1/discounts" \
    -H "Authorization: Bearer {{API_KEY}}" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Black Friday 20%",
      "percent_off_basis_points": 2000,
      "type": "percentage"
    }'
  ```

  ```bash fixed theme={}
  curl -X POST "https://api.chargefy.io/v1/discounts" \
    -H "Authorization: Bearer {{API_KEY}}" \
    -H "Content-Type: application/json" \
    -d '{
      "amount_off": 1500,
      "currency": "brl",
      "name": "Black Friday R$15",
      "type": "fixed"
    }'
  ```
</RequestExample>

## Resposta

`200 OK` com o objeto `discount` completo.

<ResponseExample>
  ```json 200 theme={}
  {
    "id": "disc_123",
    "object": "discount",
    "amount_off": null,
    "applies_to": {
      "products": [
        "prod_123"
      ]
    },
    "created_at": "2026-05-21T12:00:00Z",
    "currency": null,
    "duration": "once",
    "duration_in_months": null,
    "expires_at": null,
    "is_active": true,
    "livemode": true,
    "max_redemptions": 500,
    "metadata": {
      "campaign": "black_friday"
    },
    "name": "Black Friday 20%",
    "percent_off_basis_points": 2000,
    "redemptions_count": 0,
    "starts_at": null,
    "type": "percentage",
    "updated_at": null,
    "valid": true
  }
  ```
</ResponseExample>
