# Create consumption by code (https://docs.loybox.com.ar/en/api-reference/consumos/crear-por-codigo)



<Endpoint method="POST" path="/v1/consumptions/client-code" auth="api-key" />

Records a new consumption using the member's code. This is the call that earns the
points of a purchase.

The member has to exist: if the code does not match any client, the call returns
`404` and nothing is recorded. If you would rather the consumption be recorded
anyway, use
[create consumption by email](https://docs.loybox.com.ar/api-reference/consumos/crear-por-email).

## Body
<Fields>
  <Field name="client_code" type="integer" required="true">
    The code of the member who made the purchase.
  </Field>

  <Field name="amount" type="integer" required="true">
    The purchase amount, in whole units of the commerce's currency.
  </Field>

  <Field name="counter_id" type="integer">
    Id of the register where the purchase was made.
  </Field>

  <Field name="id_suc" type="integer">
    Id of the location where the purchase was made.
  </Field>
</Fields>

## Example
```bash
curl -X POST https://loybox-public-api-752998171300.southamerica-west1.run.app/v1/consumptions/client-code \
  -H "Authorization: Bearer $LOYBOX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "client_code": 12345,
    "amount": 1750,
    "counter_id": 2,
    "id_suc": 1
  }'
```

```json
// 201 Created
{
  "message": "Consumption created successfully"
}
```

The response does not say how many points it earned. To see that, look the member
up with
[`GET /v1/clients/{client_code}`](https://docs.loybox.com.ar/api-reference/clientes/obtener).

## Errors
| Code  | When                                                                                                                  |
| ----- | --------------------------------------------------------------------------------------------------------------------- |
| `400` | The consumption could not be created.                                                                                 |
| `403` | The client exists but is not eligible to have consumptions.                                                           |
| `404` | The client does not exist.                                                                                            |
| `422` | A body field is missing or has the wrong type. See [Validation errors](https://docs.loybox.com.ar/api-reference/errores#errores-de-validación). |
