---
title: "Create API key"
method: POST
path: "/api/api_keys"
tags: ["API Keys"]
---

# Create API key

`POST /api/api_keys`

## Request

- Base URL: `https://api.postproxy.dev`
- URL: `https://api.postproxy.dev/api/api_keys`
- Auth: HTTP bearer

Creates an API key scoped to a profile group. The response is the only place the token is returned - store it immediately. Requires an account-wide API key; only scoped keys can be minted, so there is no API path to a second account-wide key. Keys are environment-bound: the target profile group must be in the caller's environment. Send an Idempotency-Key header to make the call safe to retry - a retried create returns the original key rather than minting a second one.

## Request body

- object
  - `profile_group_id` string, required: Profile group to scope the key to. Must belong to your account and match the caller's environment.
  - `name` string: Label for the key, shown in the web app.

## Response `201`

The created key, token included (returned only here)

- ApiKey
  - `id` string: API key ID, used in the revoke URL.
  - `name` string, nullable: Label given to the key.
  - `profile_group_id` string: The profile group the key is scoped to.
  - `sandbox` boolean: true for sandbox keys.
  - `token` string: The secret bearer token. Returned only in the create response.
  - `created_at` string, date-time

## Other responses

- `401`: profile_group_id does not resolve to a group of your account in this environment
- `422`: profile_group_id missing, or the caller is a group-scoped key or an OAuth token

---

[API](https://skmtc.dev/postproxy/apis/postproxy-social-media-api.md) - [All operations](https://skmtc.dev/postproxy/apis/postproxy-social-media-api/llms.txt) - [OpenAPI document](https://skmtc.dev/postproxy/apis/postproxy-social-media-api/revisions/d54482ac4ce7?raw)
