# Check usage

Source: https://docs.orbytelabs.com/api-reference/events/checkEvent

## POST /v1/check

```json
{
  "operationId": "checkEvent",
  "tags": [
    "Events"
  ],
  "summary": "Check feature access and available credits",
  "description": "Read-only feature access and balance check. Unknown identities preview the sum of customer.created grant policies listing this feature without creating records. Only unexpired, unexhausted grants listing this feature contribute to availableCredits. Subscription grants also require an active or trialing subscription before its access expiry; purchased grants work independently. The feature must exist in the environment's active, ready deployment. For a distinct feature, supply the configured grouping field in payload. The first distinct use needs funds for one unit, and an already counted use needs only a positive matching balance. Count features always require funds for one event at the deployed price. minimumBalance is optional; a positive matching balance is always required, including for zero-cost features. Credit amounts use decimal strings in JSON. Denials return 200 with allowed: false and a reason. No credits are reserved: tracking calculates the actual event charge and checks funds atomically. Refresh at nextChangeAt to account for expiry or rollover.",
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "parameters": [
    {
      "schema": {
        "type": "string",
        "minLength": 1,
        "description": "Required for environment-scoped OAuth operations. API keys remain bound to their own environment."
      },
      "required": false,
      "description": "Required for environment-scoped OAuth operations. API keys remain bound to their own environment.",
      "name": "X-Orbyte-Environment",
      "in": "header"
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "$schema": "https://json-schema.org/draft/2020-12/schema",
          "properties": {
            "identity": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "featureKey": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[a-z][a-z0-9_-]*$"
            },
            "payload": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {}
            },
            "minimumBalance": {
              "type": "string",
              "pattern": "^-?(0|[1-9][0-9]*)$",
              "maxLength": 20
            }
          },
          "required": [
            "identity",
            "featureKey"
          ],
          "additionalProperties": false
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Current eligibility and available credits",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "availableCredits": {
                "type": "string",
                "pattern": "^-?(0|[1-9][0-9]*)$",
                "maxLength": 20
              },
              "asOf": {
                "type": "number",
                "description": "Server time in milliseconds when the balance was calculated."
              },
              "nextChangeAt": {
                "type": "number",
                "description": "Next expiry or rollover boundary in milliseconds. Refresh the balance then."
              },
              "allowed": {
                "type": "boolean"
              },
              "reason": {
                "type": "string",
                "enum": [
                  "feature_unavailable",
                  "insufficient_credits"
                ]
              }
            },
            "required": [
              "availableCredits",
              "asOf",
              "allowed"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "400": {
      "description": "Invalid request",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "401": {
      "description": "Unauthorized",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "403": {
      "description": "Insufficient permission",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "404": {
      "description": "Resource not found",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "409": {
      "description": "Resource or request conflict",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "413": {
      "description": "Content too large",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "415": {
      "description": "Unsupported media type",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "500": {
      "description": "Unexpected server error",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    }
  }
}
```

Complete schema: [OpenAPI 3.1 document](https://docs.orbytelabs.com/openapi.json)