notiflowsDocs
Users

Subscribe user to topic

Subscribe a user to a topic. Topics are created automatically if they don't exist.

Idempotent: If the user is already subscribed, returns the existing subscription with 200 OK.

POST
/users/{user_id}/subscriptions

Authorization

ApiKeyAuth SecretKeyAuth
x-notiflows-api-key<token>

Your project's public API key. Found in Project Settings. Starts with pk_.

In: header

x-notiflows-secret-key<token>

Your project's secret key. Found in Project Settings. Starts with sk_. Keep this secret!

In: header

Path Parameters

user_id*string

User external ID

Request Body

application/json

Subscription details

topic_name*string

Name of the topic to subscribe to. Topics are created automatically if they don't exist.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://api.notiflows.com/admin/users/user_12345/subscriptions" \  -H "Content-Type: application/json" \  -d '{    "topic_name": "order-updates"  }'
{
  "created_at": "2024-01-15T10:30:00Z",
  "id": "01HQXYZ123456789ABCDEFGHIJ",
  "topic_name": "order-updates",
  "user_id": "01HQABC987654321ZYXWVUTSRQ"
}
{
  "created_at": "2024-01-15T10:30:00Z",
  "id": "01HQXYZ123456789ABCDEFGHIJ",
  "topic_name": "order-updates",
  "user_id": "01HQABC987654321ZYXWVUTSRQ"
}
{
  "error": {
    "code": "not_found",
    "details": {
      "allowed_statuses": [
        "string"
      ],
      "allowed_transitions": [
        "string"
      ],
      "auth": "api_key",
      "current_status": "string",
      "fields": [
        {
          "field": "email",
          "message": "can't be blank",
          "reason": "required"
        }
      ],
      "id": "string",
      "idempotency_key": "string",
      "limit": 0,
      "param": "string",
      "reason": "string",
      "required_scope": "string",
      "resource": "string",
      "retry_after": 0,
      "window": "string"
    },
    "message": "User not found",
    "request_id": "req_abc123",
    "status": 404,
    "type": "https://docs.notiflows.com/errors/not_found"
  }
}
{
  "error": {
    "code": "not_found",
    "details": {
      "allowed_statuses": [
        "string"
      ],
      "allowed_transitions": [
        "string"
      ],
      "auth": "api_key",
      "current_status": "string",
      "fields": [
        {
          "field": "email",
          "message": "can't be blank",
          "reason": "required"
        }
      ],
      "id": "string",
      "idempotency_key": "string",
      "limit": 0,
      "param": "string",
      "reason": "string",
      "required_scope": "string",
      "resource": "string",
      "retry_after": 0,
      "window": "string"
    },
    "message": "User not found",
    "request_id": "req_abc123",
    "status": 404,
    "type": "https://docs.notiflows.com/errors/not_found"
  }
}
{
  "error": {
    "code": "not_found",
    "details": {
      "allowed_statuses": [
        "string"
      ],
      "allowed_transitions": [
        "string"
      ],
      "auth": "api_key",
      "current_status": "string",
      "fields": [
        {
          "field": "email",
          "message": "can't be blank",
          "reason": "required"
        }
      ],
      "id": "string",
      "idempotency_key": "string",
      "limit": 0,
      "param": "string",
      "reason": "string",
      "required_scope": "string",
      "resource": "string",
      "retry_after": 0,
      "window": "string"
    },
    "message": "User not found",
    "request_id": "req_abc123",
    "status": 404,
    "type": "https://docs.notiflows.com/errors/not_found"
  }
}
{
  "error": {
    "code": "not_found",
    "details": {
      "allowed_statuses": [
        "string"
      ],
      "allowed_transitions": [
        "string"
      ],
      "auth": "api_key",
      "current_status": "string",
      "fields": [
        {
          "field": "email",
          "message": "can't be blank",
          "reason": "required"
        }
      ],
      "id": "string",
      "idempotency_key": "string",
      "limit": 0,
      "param": "string",
      "reason": "string",
      "required_scope": "string",
      "resource": "string",
      "retry_after": 0,
      "window": "string"
    },
    "message": "User not found",
    "request_id": "req_abc123",
    "status": 404,
    "type": "https://docs.notiflows.com/errors/not_found"
  }
}
{
  "error": {
    "code": "not_found",
    "details": {
      "allowed_statuses": [
        "string"
      ],
      "allowed_transitions": [
        "string"
      ],
      "auth": "api_key",
      "current_status": "string",
      "fields": [
        {
          "field": "email",
          "message": "can't be blank",
          "reason": "required"
        }
      ],
      "id": "string",
      "idempotency_key": "string",
      "limit": 0,
      "param": "string",
      "reason": "string",
      "required_scope": "string",
      "resource": "string",
      "retry_after": 0,
      "window": "string"
    },
    "message": "User not found",
    "request_id": "req_abc123",
    "status": 404,
    "type": "https://docs.notiflows.com/errors/not_found"
  }
}
{
  "error": {
    "code": "not_found",
    "details": {
      "allowed_statuses": [
        "string"
      ],
      "allowed_transitions": [
        "string"
      ],
      "auth": "api_key",
      "current_status": "string",
      "fields": [
        {
          "field": "email",
          "message": "can't be blank",
          "reason": "required"
        }
      ],
      "id": "string",
      "idempotency_key": "string",
      "limit": 0,
      "param": "string",
      "reason": "string",
      "required_scope": "string",
      "resource": "string",
      "retry_after": 0,
      "window": "string"
    },
    "message": "User not found",
    "request_id": "req_abc123",
    "status": 404,
    "type": "https://docs.notiflows.com/errors/not_found"
  }
}