---
title: "Create a topic"
method: POST
path: "/v2/topics"
tags: ["Topics"]
---

# Create a topic

`POST /v2/topics`

## Request

- Base URL: `https://api.notifly.io`
- URL: `https://api.notifly.io/v2/topics`
- Auth: API key in header `Authorization`

Creates a new topic if it does not exist, or updates an existing topic if it already exists. Use ?failIfExists=true to prevent updates.

## Query parameters

- `failIfExists` boolean

## Request body

- CreateUpdateTopicRequestDto
  - `key` string, required: The unique key identifier for the topic. The key must contain only alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), underscores (_), colons (:), or be a valid email address.
  - `name` string: The display name for the topic
  - `data` object, nullable: Additional custom data associated with the topic. Flat key-value pairs of scalars (string, number, boolean, string[]). Maximum size: 64KB.

## Response `200`

OK

- object
  - `data` TopicResponseDto
    - `_id` string, required: The identifier of the topic
    - `key` string, required: The unique key of the topic
    - `name` string: The name of the topic
    - `data` object: Additional custom data associated with the topic
    - `createdAt` string: The date the topic was created
    - `updatedAt` string: The date the topic was last updated

## Other responses

- `201`: Created
- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not Found
- `405`: Method Not Allowed
- `409`: Topic already exists (when query param failIfExists=true)
- `413`: Payload Too Large
- `414`: URI Too Long
- `415`: Unsupported Media Type
- `422`: Unprocessable Entity
- `429`: The client has sent too many requests in a given amount of time.
- `500`: Internal Server Error
- `503`: The server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay.

---

[API](https://skmtc.dev/notifly/apis/notifly-api.md) · [All operations](https://skmtc.dev/notifly/apis/notifly-api/llms.txt) · [OpenAPI document](https://skmtc.dev/notifly/apis/notifly-api/revisions/af909b9e1e57?raw)
