# Create grant

Source: https://docs.orbytelabs.com/api-reference/grants/createGrant

## POST /v1/grants

```json
{
  "operationId": "createGrant",
  "tags": [
    "Grants"
  ],
  "summary": "Grant credits directly to a customer",
  "description": "Creates the customer when needed and issues a manual grant without collecting payment or calling Stripe. credits uses integer ledger units, where one credit is 1000000000 units. Credits can fund any deployed feature by default, including features added later. Set featureKeys to restrict access to specific features. Listed keys must be unique and belong to the active, ready deployment. An empty list grants no feature access. Optional expiresAt is a future Unix timestamp in milliseconds. Omitted expiry means no expiry. An idempotencyKey is required and scoped to this environment's manual grants. Repeating the same terms returns the original grant, including after expiry or catalog changes. Reusing a key with different terms returns 409. Feature order is ignored. Manual grants fund usage independently of subscriptions.",
  "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
            },
            "credits": {
              "type": "string",
              "pattern": "^-?(0|[1-9][0-9]*)$",
              "maxLength": 20
            },
            "featureKeys": {
              "maxItems": 500,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128,
                "pattern": "^[a-z][a-z0-9_-]*$"
              }
            },
            "expiresAt": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "idempotencyKey": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          },
          "required": [
            "identity",
            "credits",
            "idempotencyKey"
          ],
          "additionalProperties": false
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Created grant ID, including idempotent replays",
      "content": {
        "application/json": {
          "schema": {
            "type": "string",
            "$schema": "https://json-schema.org/draft/2020-12/schema"
          }
        }
      }
    },
    "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)