---
title: "Make an access code to hand out. The code is in this response only."
method: POST
path: "/v1/admin/codes"
tags: ["admin"]
---

# Make an access code to hand out. The code is in this response only.

`POST /v1/admin/codes`

## Request

- Base URL: `https://api.hookdetector.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.hookdetector.com/v1/admin/codes`
- Auth: none declared

Make a beta access code to send however you like. max_uses (1 to 100000, default 1)
is how many accounts it may create; expires_in_days (1 to 365) is optional; note is
your own. email binds it to one person: then only Google sign-in with that verified
email redeems it, never REST or MCP; leave it out for a code that works on every door.
The full code is in this response and nowhere else, ever. Needs the admin scope and an
admin account. MCP: create_access_code.

## Headers

- `authorization` string, nullable: Bearer hd_... from POST /v1/accounts or POST /v1/keys

## Request body

- AccessCodeIn
  - `email` string, nullable: bind the code to this person: then only Google sign-in with this verified email redeems it, never REST or MCP. Leave out (the default) for a code anyone holding it may use on any door
  - `note` string, nullable: your own note, up to 500 characters
  - `max_uses` integer, nullable: how many accounts it may create, 1 to 100000; 1 when left out
  - `expires_in_days` integer, nullable: 1 to 365; never expires when left out

## Response `201`

Successful Response

- AccessCodeCreatedOut
  - `code_id` string, required
  - `code_prefix` string, required: the first 7 characters, to tell codes apart
  - `email` string, nullable, required
  - `note` string, nullable, required
  - `source` 'owner' | 'request' | 'proof' | 'other', required
  - `max_uses` integer, required
  - `uses` integer, required
  - `expires_at` string, nullable, required
  - `revoked_at` string, nullable, required
  - `created_at` string, required
  - `usable` boolean, required: not revoked, not expired, not used up
  - `code` string, required: the code, shown here once and never again
  - `message` string, required

## Other responses

- `401`: missing, invalid, revoked or expired API key (code key_expired)
- `403`: the key lacks the admin scope (insufficient_scope), or its account is not the owner's (admin_required)
- `413`: request body over the size cap
- `422`: invalid input
- `500`: our fault; names the request id

---

[API](https://skmtc.dev/hookdetector/apis/hook-detector.md) · [All operations](https://skmtc.dev/hookdetector/apis/hook-detector/llms.txt) · [OpenAPI document](https://skmtc.dev/hookdetector/apis/hook-detector/revisions/b136a2804d2b?raw)
