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

# Consume usage

> Synchronously apply usage and return the allow or deny decision.

<RequestExample>
  ```ts theme={null}
  const { result, error } = await unprice.usage.consume({
    idempotencyKey: "idem_123",
    eventSlug: "completions",
    featureSlug: "ai-messages",
    customerId: "cus_1234567890",
    properties: {
      aiMessages: 1,
      inputTokens: 1840,
      outputTokens: 620,
      model: "gpt-4.1-mini"
    }
  });

  if (error) {
    console.error(error.message);
    return;
  }

  console.log(result);
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "allowed": true,
    "state": "processed"
  }
  ```
</ResponseExample>

## Request

<ParamField body="featureSlug" type="string" required>
  The specific feature or entitlement to consume against, for example `ai-messages`.
</ParamField>

<ParamField body="idempotencyKey" type="string" required>
  Logical key used to deduplicate the event.
</ParamField>

<ParamField body="eventSlug" type="string" required>
  The broad event kind configured in Unprice, for example `completions`.
</ParamField>

<ParamField body="properties" type="object" required>
  Event properties used by meters. For `usage.consume`, the targeted feature's meter reads the
  relevant field from this object.
</ParamField>

## Response

Returns whether the event was processed or rejected for the targeted feature. Use this when the
request path needs an enforcing decision before paid work runs.
