Create consumption by code

Records a purchase using the member's code, so it earns points.

POST/v1/consumptions/client-codeCommerce 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.

Body

client_codeintegerrequired

The code of the member who made the purchase.

amountintegerrequired

The purchase amount, in whole units of the commerce's currency.

counter_idinteger

Id of the register where the purchase was made.

id_sucinteger

Id of the location where the purchase was made.

Example

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
  }'
// 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}.

Errors

CodeWhen
400The consumption could not be created.
403The client exists but is not eligible to have consumptions.
404The client does not exist.
422A body field is missing or has the wrong type. See Validation errors.

On this page