---
title: "Create an API key"
method: POST
path: "/api/v1/organizations/{organizationId}/api-keys"
tags: ["API keys"]
---

# Create an API key

`POST /api/v1/organizations/{organizationId}/api-keys`

## Request

- Base URL: `https://app.easyscraper.com`
- URL: `https://app.easyscraper.com/api/v1/organizations/{organizationId}/api-keys`
- Auth: API key in cookie `better-auth.session_token`

Create an API key for the organization, with a role (`member` or `admin`) whose permissions it gets and an optional expiry. Returns the key itself (`key`) only this once; store it somewhere safe. Requires the `apiKey: ["create"]` permission (owners and admins)

## Path parameters

- `organizationId` string, uuid, required

## Request body

- object
  - `name` string, required
  - `role` 'member' | 'admin', required
  - `expiresInDays` union, required
    - unknown
    - unknown
    - unknown
    - unknown

## Response `200`

OK

- object
  - `apiKey` object, required
    - `id` string, required
    - `name` string, required
    - `start` string, nullable, required
    - `role` 'member' | 'admin', nullable, required
    - `expiresAt` string, date-time, nullable, required
    - `expired` boolean, required
    - `lastUsedAt` string, date-time, nullable, required
    - `createdAt` string, date-time, required
    - `createdBy` object, nullable, required
      - `name` string, required
      - `email` string, required
  - `key` string, required

## Other responses

- `400`: 400
- `401`: 401
- `403`: 403
- `404`: 404
- `429`: 429

## Changes

- **2026-11-02** `a12cef98c52b`: 1 info
  - added the non-success response with the status `400`
- **2026-10-31** `3e642e95991a`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/easyscraper/apis/easy-scraper-api/changes/api/v1/organizations/:organizationId/api-keys/post.md)

---

[API](https://skmtc.dev/easyscraper/apis/easy-scraper-api.md) - [All operations](https://skmtc.dev/easyscraper/apis/easy-scraper-api/llms.txt) - [OpenAPI document](https://skmtc.dev/easyscraper/apis/easy-scraper-api/revisions/a12cef98c52b?raw)
