---
title: "Create"
method: POST
path: "/v1/api_keys"
tags: ["Api Keys"]
---

# Create

`POST /v1/api_keys`

Creates a new api key.

## Request body

- ApiKeyCreateSpec — Api key creation specification
  - `name` string — name
  - `expiry` string — 2024-12-22T17:24:32.162-05:00 intended expiry

## Response `201`

created api key

- object
  - `data` ApiKeySpec — ApiKey specification
    - `id` string — Resource Id (integer or uuid)
    - `type` string — Resource type name
    - `uuid` string — Resource UUID (if applicable)
    - `attributes` ApiKey — ApiKey resource
      - `name` string — name
      - `expiry` string — 2024-12-22T17:24:32.162-05:00 intended expiry
      - `last_four` string — last four digits of the token
      - `token` string — full token on initial create or a redacted token with last four. i.e: ***************Lhz4
      - `status` string — token status (active, revoked)
      - `created_at` string — created at datetime 2024-09-20T15:59:59.100-04:00
      - `updated_at` string — date last updated 2024-09-20T15:59:59.100-04:00
      - `user_id:` integer — associated user to api key

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `422` — Can not create api_key with the specified data

---

[API](https://skmtc.net/dnsfilter/apis/dnsfilter-api.md) · [All operations](https://skmtc.net/dnsfilter/apis/dnsfilter-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/dnsfilter/dnsfilter-api/revisions/29e5e6ee3316/schema)
