{
  "openapi": "3.0.0",
  "paths": {
    "/v1/api/contacts": {
      "post": {
        "deprecated": true,
        "operationId": "ApiController_createContact_v1",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateContactDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Contact created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactDto"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Authentication is required or the API key is invalid.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "The request rate limit was exceeded.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying the request.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected Replyn API error occurred.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "summary": "Create a new contact",
        "tags": [
          "API (deprecated)"
        ],
        "description": "Create a new contact"
      }
    },
    "/v1/api/contacts/{id}": {
      "get": {
        "deprecated": true,
        "operationId": "ApiController_getContact_v1",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Contact ID",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the contact",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactDto"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "The request is invalid.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Authentication is required or the API key is invalid.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Contact not found",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "429": {
            "description": "The request rate limit was exceeded.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying the request.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected Replyn API error occurred.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "summary": "Get a contact by ID",
        "tags": [
          "API (deprecated)"
        ],
        "description": "Get a contact by ID"
      }
    },
    "/v1/api/channels/{channelId}/send-message": {
      "post": {
        "deprecated": true,
        "operationId": "ApiController_sendMessage_v1",
        "parameters": [
          {
            "name": "channelId",
            "required": true,
            "in": "path",
            "description": "Channel ID to send the message through",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMessageDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Message sent successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendMessageResponseDto"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid message data",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Authentication is required or the API key is invalid.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Channel not found",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "429": {
            "description": "The request rate limit was exceeded.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying the request.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected Replyn API error occurred.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "summary": "Send a message through a channel",
        "tags": [
          "API (deprecated)"
        ],
        "description": "Send a message through a channel"
      }
    },
    "/v1/api/contacts/{id}/note": {
      "post": {
        "deprecated": true,
        "operationId": "ApiController_createNote_v1",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Contact ID",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateNoteDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Note created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivityDto"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Authentication is required or the API key is invalid.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Contact not found",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "429": {
            "description": "The request rate limit was exceeded.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying the request.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected Replyn API error occurred.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum number of requests permitted in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Number of requests remaining in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the current rate-limit window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "summary": "Create a note for a contact",
        "tags": [
          "API (deprecated)"
        ],
        "description": "Create a note for a contact"
      }
    }
  },
  "info": {
    "title": "Replyn Developer API",
    "description": "The Replyn REST API for contacts, conversations, and messaging. Authenticate with an API key in the Authorization header.",
    "version": "0.1",
    "contact": {}
  },
  "tags": [],
  "servers": [
    {
      "url": "https://api.replyn.io"
    }
  ],
  "components": {
    "securitySchemes": {
      "api-key": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization"
      }
    },
    "schemas": {
      "ContactReferralDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "ad",
              "website"
            ],
            "description": "Type of referral",
            "example": "ad"
          },
          "adId": {
            "type": "string",
            "description": "The ad platform's own advertisement ID, e.g. Meta's — NOT a Replyn ad id (required when type is \"ad\")",
            "example": "120209876543210000"
          },
          "adName": {
            "type": "string",
            "description": "Name/title of the advertisement (required when type is \"ad\")",
            "example": "Summer Sale Campaign"
          },
          "adSource": {
            "type": "string",
            "description": "Source of advertisement (required when type is \"ad\")",
            "example": "whatsapp, instagram, google ads"
          },
          "adThumbnail": {
            "type": "string",
            "nullable": true,
            "description": "URL to the advertisement thumbnail",
            "example": "https://example.com/thumbnail.jpg"
          },
          "adVideoUrl": {
            "type": "string",
            "nullable": true,
            "description": "URL to the advertisement video",
            "example": "https://example.com/video.mp4"
          },
          "adPhotoUrl": {
            "type": "string",
            "nullable": true,
            "description": "URL to the advertisement photo/image",
            "example": "https://example.com/photo.jpg"
          },
          "url": {
            "type": "string",
            "description": "Full URL of the referring website page (required when type is \"website\")",
            "example": "https://example.com/pricing?utm_source=google&utm_medium=cpc"
          },
          "pageTitle": {
            "type": "string",
            "nullable": true,
            "description": "Title of the page the contact visited"
          },
          "referrer": {
            "type": "string",
            "nullable": true,
            "description": "HTTP referrer value"
          }
        },
        "required": [
          "type"
        ]
      },
      "CreateContactDto": {
        "type": "object",
        "properties": {
          "firstName": {
            "type": "string",
            "nullable": true,
            "description": "First name of the contact",
            "example": "John"
          },
          "lastName": {
            "type": "string",
            "nullable": true,
            "description": "Last name of the contact",
            "example": "Doe"
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "description": "Phone number in E.164 format",
            "example": "+1234567890"
          },
          "email": {
            "type": "string",
            "nullable": true,
            "description": "Email address of the contact",
            "example": "john.doe@example.com"
          },
          "country": {
            "type": "string",
            "nullable": true,
            "description": "ISO 3166-1 alpha-2 country code",
            "example": "US"
          },
          "language": {
            "type": "string",
            "nullable": true,
            "description": "ISO 639-1 language code",
            "example": "en"
          },
          "address": {
            "type": "string",
            "nullable": true,
            "description": "Physical address of the contact",
            "example": "123 Main St, New York, NY 10001"
          },
          "imageUrl": {
            "type": "string",
            "nullable": true,
            "description": "URL to the contact profile image",
            "example": "https://example.com/avatar.jpg"
          },
          "lifecycleId": {
            "type": "string",
            "nullable": true,
            "description": "ID of the lifecycle stage for this contact",
            "example": "clxyz123..."
          },
          "assignedUserId": {
            "type": "object",
            "nullable": true,
            "description": "ID of the user assigned to this contact",
            "example": "clxyz456..."
          },
          "assignedTeamId": {
            "type": "object",
            "nullable": true,
            "description": "ID of the team assigned to this contact",
            "example": "clxyz456..."
          },
          "isAiActive": {
            "type": "boolean",
            "description": "Whether the AI agent is actively handling this conversation"
          },
          "status": {
            "type": "string",
            "enum": [
              "closed",
              "open",
              "snoozed"
            ],
            "description": "Conversation status of the contact",
            "example": "open"
          },
          "snoozedUntil": {
            "format": "date-time",
            "type": "string",
            "nullable": true,
            "description": "Date until which the contact is snoozed",
            "example": "2025-12-31T23:59:59.000Z"
          },
          "blocked": {
            "type": "boolean",
            "nullable": true,
            "description": "Whether the contact is blocked",
            "example": false
          },
          "origin": {
            "type": "string",
            "enum": [
              "ad",
              "organic",
              "referral",
              "manual",
              "api",
              "import",
              "clinicsoft"
            ],
            "description": "First-touch origin, declared by the staff member creating the contact. Omitted, it is derived (referral when a referrer is named, api for the API source, manual otherwise). Never editable afterwards."
          },
          "tags": {
            "nullable": true,
            "description": "List of tags associated with the contact",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "followUpCompleted": {
            "type": "boolean",
            "nullable": true,
            "description": "Whether the follow-up was completed (vs just cleared/removed)"
          },
          "value": {
            "type": "number",
            "nullable": true,
            "description": "Monetary value of the contact. Accepts a number or a numeric string.",
            "example": 1500
          },
          "dynamicValues": {
            "type": "object",
            "description": "Values for the workspace's own contact fields, keyed by the field's key. Keys with no matching definition are dropped.",
            "example": {
              "mrn": 7117
            }
          },
          "treatments": {
            "nullable": true,
            "description": "Treatment names (array or comma-separated string, e.g. \"Hair Transplant, IV Derma\")",
            "example": "Hair Transplant, IV Derma",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "treatmentIds": {
            "nullable": true,
            "description": "List of treatment IDs (array or comma-separated string)",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "productIds": {
            "nullable": true,
            "description": "List of product IDs to associate with the contact",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "referredByName": {
            "type": "string",
            "nullable": true,
            "description": "Name of whoever referred this contact. Staff-declared at creation only; never editable afterwards."
          },
          "referral": {
            "nullable": true,
            "description": "Referral data (ad or website)",
            "allOf": [
              {
                "$ref": "#/components/schemas/ContactReferralDto"
              }
            ]
          }
        }
      },
      "FollowUpDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "reason": {
            "type": "object",
            "nullable": true
          },
          "dueAt": {
            "format": "date-time",
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "user",
              "workflow",
              "playbook",
              "system",
              "ai"
            ]
          },
          "skipWhatsapp": {
            "type": "boolean"
          },
          "reminderSentAt": {
            "type": "object",
            "nullable": true
          }
        },
        "required": [
          "id",
          "reason",
          "dueAt",
          "source",
          "skipWhatsapp",
          "reminderSentAt"
        ]
      },
      "ContactChannelDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "object",
            "nullable": true
          },
          "identifier": {
            "type": "object",
            "nullable": true
          },
          "lastMessageSentByUserAt": {
            "type": "object",
            "nullable": true
          },
          "lastCommentSentByUserAt": {
            "type": "object",
            "nullable": true
          },
          "metadata": {
            "type": "object",
            "nullable": true
          },
          "type": {
            "type": "object",
            "nullable": true
          }
        },
        "required": [
          "id",
          "identifier",
          "lastMessageSentByUserAt",
          "lastCommentSentByUserAt",
          "metadata",
          "type"
        ]
      },
      "AdDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "externalId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "object",
            "nullable": true
          },
          "aiGeneratedDescription": {
            "type": "object",
            "nullable": true
          },
          "videoUrl": {
            "type": "object",
            "nullable": true
          },
          "imageUrl": {
            "type": "object",
            "nullable": true
          },
          "thumbnailUrl": {
            "type": "object",
            "nullable": true
          },
          "productId": {
            "type": "object",
            "nullable": true
          },
          "source": {
            "type": "string"
          },
          "mediaId": {
            "type": "object",
            "nullable": true
          },
          "adAccountId": {
            "type": "object",
            "nullable": true
          },
          "adsetId": {
            "type": "object",
            "nullable": true
          },
          "campaignId": {
            "type": "object",
            "nullable": true
          },
          "adsetExternalId": {
            "type": "object",
            "nullable": true
          },
          "adsetName": {
            "type": "object",
            "nullable": true
          },
          "campaignExternalId": {
            "type": "object",
            "nullable": true
          },
          "campaignName": {
            "type": "object",
            "nullable": true
          },
          "status": {
            "type": "object",
            "nullable": true
          },
          "previewUrl": {
            "type": "object",
            "nullable": true
          },
          "instagramPermalinkUrl": {
            "type": "object",
            "nullable": true
          },
          "adInsights": {
            "type": "object",
            "nullable": true
          },
          "conversionType": {
            "type": "object",
            "nullable": true
          },
          "organizationId": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "createdAt": {
            "format": "date-time",
            "type": "string"
          },
          "updatedAt": {
            "type": "object",
            "nullable": true
          },
          "attachedSummary": {
            "type": "object",
            "nullable": true
          }
        },
        "required": [
          "id",
          "externalId",
          "name",
          "description",
          "aiGeneratedDescription",
          "videoUrl",
          "imageUrl",
          "thumbnailUrl",
          "productId",
          "source",
          "mediaId",
          "adAccountId",
          "adsetId",
          "campaignId",
          "adsetExternalId",
          "adsetName",
          "campaignExternalId",
          "campaignName",
          "status",
          "previewUrl",
          "instagramPermalinkUrl",
          "adInsights",
          "conversionType",
          "organizationId",
          "workspaceId",
          "createdAt",
          "updatedAt",
          "attachedSummary"
        ]
      },
      "WebsiteDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "domain": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "organizationId": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "createdAt": {
            "format": "date-time",
            "type": "string"
          },
          "updatedAt": {
            "type": "object",
            "nullable": true
          }
        },
        "required": [
          "id",
          "domain",
          "name",
          "organizationId",
          "workspaceId",
          "createdAt"
        ]
      },
      "ContactWebsiteDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "contactId": {
            "type": "string"
          },
          "websiteId": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "pagePath": {
            "type": "object",
            "nullable": true
          },
          "pageTitle": {
            "type": "object",
            "nullable": true
          },
          "utmSource": {
            "type": "object",
            "nullable": true
          },
          "utmMedium": {
            "type": "object",
            "nullable": true
          },
          "utmCampaign": {
            "type": "object",
            "nullable": true
          },
          "utmTerm": {
            "type": "object",
            "nullable": true
          },
          "utmContent": {
            "type": "object",
            "nullable": true
          },
          "referrer": {
            "type": "object",
            "nullable": true
          },
          "createdAt": {
            "format": "date-time",
            "type": "string"
          },
          "website": {
            "$ref": "#/components/schemas/WebsiteDto"
          }
        },
        "required": [
          "id",
          "contactId",
          "websiteId",
          "url",
          "createdAt"
        ]
      },
      "FormDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "externalId": {
            "type": "object",
            "nullable": true,
            "description": "Provider's form id (e.g. Meta form_id)"
          },
          "name": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "description": "Platform the form lives on, e.g. 'meta', 'tiktok', 'snapchat', 'website'"
          },
          "url": {
            "type": "object",
            "nullable": true
          },
          "createdAt": {
            "format": "date-time",
            "type": "string"
          },
          "submissionCount": {
            "type": "number",
            "description": "Number of submissions recorded for this form"
          }
        },
        "required": [
          "id",
          "name",
          "source",
          "createdAt"
        ]
      },
      "FormSubmissionDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "contactId": {
            "type": "string"
          },
          "formId": {
            "type": "string"
          },
          "externalId": {
            "type": "object",
            "nullable": true,
            "description": "Provider's lead/submission id"
          },
          "adId": {
            "type": "object",
            "nullable": true,
            "description": "Internal ad id when the fill came from a lead ad"
          },
          "websiteVisitId": {
            "type": "object",
            "nullable": true,
            "description": "Contact-website-visit id for the contact's most recent visit at submission time"
          },
          "fields": {
            "description": "Submitted answers as [{ question, value }]",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "submittedAt": {
            "format": "date-time",
            "type": "string"
          },
          "createdAt": {
            "format": "date-time",
            "type": "string"
          },
          "form": {
            "$ref": "#/components/schemas/FormDto"
          }
        },
        "required": [
          "id",
          "contactId",
          "formId",
          "fields",
          "submittedAt",
          "createdAt"
        ]
      },
      "ContactDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "firstName": {
            "type": "object",
            "nullable": true
          },
          "lastName": {
            "type": "object",
            "nullable": true
          },
          "address": {
            "type": "object",
            "nullable": true
          },
          "phone": {
            "type": "object",
            "nullable": true
          },
          "email": {
            "type": "object",
            "nullable": true
          },
          "humanAgentRequired": {
            "type": "boolean",
            "description": "The AI handed this contact off to a human (cleared on human takeover)."
          },
          "knowledgeGapPending": {
            "type": "boolean",
            "description": "The AI logged an unanswered knowledge gap for this contact; cleared once the answer is captured, accepted, or dismissed."
          },
          "pendingDraft": {
            "type": "object",
            "nullable": true,
            "description": "The drafted AI reply waiting for human review, or null. Cleared when the draft is sent, discarded, or superseded. `stepId` is the response step send/edit/discard resolve."
          },
          "country": {
            "type": "object",
            "nullable": true
          },
          "language": {
            "type": "object",
            "nullable": true
          },
          "imageUrl": {
            "type": "object",
            "nullable": true
          },
          "username": {
            "type": "object",
            "nullable": true
          },
          "blocked": {
            "type": "object",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "closed",
              "snoozed"
            ],
            "nullable": true
          },
          "snoozedUntil": {
            "type": "object",
            "nullable": true
          },
          "assignedUserId": {
            "type": "object",
            "nullable": true
          },
          "assignedTeamId": {
            "type": "object",
            "nullable": true
          },
          "isAiActive": {
            "type": "boolean",
            "description": "Whether the AI agent is actively handling this conversation"
          },
          "lastMessageProcessedAt": {
            "type": "object",
            "nullable": true
          },
          "lastMessageOwner": {
            "type": "string",
            "enum": [
              "contact",
              "user",
              "ai",
              "workflow",
              "broadcast",
              "api",
              "account"
            ],
            "nullable": true
          },
          "lastMessageId": {
            "type": "object",
            "nullable": true
          },
          "lifecycleId": {
            "type": "object",
            "nullable": true
          },
          "origin": {
            "type": "string",
            "enum": [
              "ad",
              "organic",
              "referral",
              "manual",
              "api",
              "import",
              "clinicsoft"
            ],
            "nullable": true,
            "description": "First-touch origin, written once at creation and never editable afterwards."
          },
          "referredByName": {
            "type": "object",
            "nullable": true
          },
          "followUp": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/FollowUpDto"
              }
            ]
          },
          "lastSummary": {
            "type": "object",
            "nullable": true
          },
          "lastNote": {
            "type": "object",
            "nullable": true
          },
          "lastNoteAt": {
            "type": "object",
            "nullable": true
          },
          "lastNoteActivityId": {
            "type": "object",
            "nullable": true
          },
          "value": {
            "type": "string"
          },
          "dynamicValues": {
            "type": "object",
            "description": "Values for the workspace's own contact fields, keyed by field key",
            "example": {
              "mrn": 7117
            }
          },
          "sortOrder": {
            "type": "number"
          },
          "organizationId": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "createdAt": {
            "format": "date-time",
            "type": "string"
          },
          "updatedAt": {
            "type": "object",
            "nullable": true
          },
          "tags": {
            "type": "object",
            "nullable": true
          },
          "channels": {
            "$ref": "#/components/schemas/ContactChannelDto"
          },
          "treatments": {
            "type": "object",
            "nullable": true
          },
          "treatmentIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "productIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "adIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "lastAdId": {
            "type": "object",
            "nullable": true
          },
          "lastAd": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/AdDto"
              }
            ]
          },
          "websiteIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "lastWebsiteVisitId": {
            "type": "object",
            "nullable": true
          },
          "lastWebsiteVisit": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/ContactWebsiteDto"
              }
            ]
          },
          "formIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "lastFormSubmissionId": {
            "type": "object",
            "nullable": true
          },
          "lastFormSubmission": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/FormSubmissionDto"
              }
            ]
          }
        },
        "required": [
          "id",
          "firstName",
          "lastName",
          "address",
          "phone",
          "email",
          "humanAgentRequired",
          "knowledgeGapPending",
          "pendingDraft",
          "country",
          "language",
          "imageUrl",
          "username",
          "blocked",
          "status",
          "snoozedUntil",
          "assignedUserId",
          "assignedTeamId",
          "isAiActive",
          "lastMessageProcessedAt",
          "lastMessageOwner",
          "lastMessageId",
          "lifecycleId",
          "origin",
          "referredByName",
          "lastSummary",
          "lastNote",
          "lastNoteAt",
          "lastNoteActivityId",
          "value",
          "dynamicValues",
          "sortOrder",
          "organizationId",
          "workspaceId",
          "createdAt",
          "updatedAt",
          "tags",
          "channels"
        ]
      },
      "TemplateVariableDto": {
        "type": "object",
        "properties": {
          "header": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "body": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "buttons": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "header",
          "body",
          "buttons"
        ]
      },
      "TemplatePayloadDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "variables": {
            "$ref": "#/components/schemas/TemplateVariableDto"
          }
        },
        "required": [
          "id",
          "variables"
        ]
      },
      "QuickReplyPayloadDto": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "buttons": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "text",
          "buttons"
        ]
      },
      "AttachmentPayloadDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "caption": {
            "type": "string"
          },
          "contentType": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "url",
          "name",
          "caption",
          "contentType"
        ]
      },
      "SendMessageDto": {
        "type": "object",
        "properties": {
          "contactId": {
            "type": "string",
            "description": "Either conversationId or phone must be provided"
          },
          "commentId": {
            "type": "string",
            "description": "The comment ID for which this text needs to be sent"
          },
          "replyTo": {
            "type": "string",
            "description": "The message ID for which this text needs to be sent"
          },
          "phoneNumber": {
            "type": "string",
            "description": "Either conversationId or phone must be provided"
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "image",
              "video",
              "audio",
              "file",
              "share",
              "template",
              "carousel_template",
              "quick_reply"
            ],
            "description": "Type of message to send"
          },
          "template": {
            "$ref": "#/components/schemas/TemplatePayloadDto"
          },
          "quickReply": {
            "$ref": "#/components/schemas/QuickReplyPayloadDto"
          },
          "text": {
            "type": "string"
          },
          "video": {
            "$ref": "#/components/schemas/AttachmentPayloadDto"
          },
          "image": {
            "$ref": "#/components/schemas/AttachmentPayloadDto"
          },
          "audio": {
            "$ref": "#/components/schemas/AttachmentPayloadDto"
          },
          "share": {
            "$ref": "#/components/schemas/AttachmentPayloadDto"
          },
          "file": {
            "$ref": "#/components/schemas/AttachmentPayloadDto"
          },
          "isAiAssisted": {
            "type": "boolean",
            "description": "The composer content was drafted/rewritten with AI assistance before sending"
          }
        },
        "required": [
          "contactId",
          "commentId",
          "replyTo",
          "phoneNumber",
          "type",
          "template",
          "quickReply",
          "text",
          "video",
          "image",
          "audio",
          "share",
          "file",
          "isAiAssisted"
        ]
      },
      "SendMessageResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "status"
        ]
      },
      "CreateNoteDto": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "mentioned": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "owner": {
            "type": "string",
            "enum": [
              "user",
              "api",
              "ai",
              "system"
            ]
          }
        },
        "required": [
          "text"
        ]
      },
      "ActivityDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "created",
              "assigned",
              "unassigned",
              "lifecycle_change",
              "conversation_status_change",
              "snooze",
              "unsnooze",
              "block",
              "unblock",
              "note",
              "ads_clicked",
              "website_visited",
              "form_submitted",
              "order_update",
              "follow_up_set",
              "follow_up_cleared",
              "follow_up_completed",
              "follow_up_due",
              "reminder_created",
              "reminder_completed",
              "reminder_removed",
              "call",
              "appointment_created",
              "appointment_updated",
              "appointment_rescheduled",
              "appointment_deleted",
              "appointment_outcome",
              "appointment_billed",
              "tag_added",
              "tag_removed",
              "ask_for_input",
              "workflow_started",
              "workflow_ended",
              "workflow_paused",
              "workflow_delayed",
              "handover_exhausted",
              "handover_parked",
              "availability_routing"
            ]
          },
          "userId": {
            "type": "object",
            "nullable": true
          },
          "contactId": {
            "type": "string"
          },
          "mentioned": {
            "nullable": true,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "owner": {
            "type": "string",
            "enum": [
              "user",
              "api",
              "ai",
              "system"
            ],
            "nullable": true
          },
          "payload": {
            "type": "object",
            "nullable": true
          },
          "organizationId": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "createdAt": {
            "format": "date-time",
            "type": "string"
          },
          "updatedAt": {
            "type": "object",
            "nullable": true
          },
          "deletedAt": {
            "type": "object",
            "nullable": true
          }
        },
        "required": [
          "id",
          "type",
          "userId",
          "contactId",
          "mentioned",
          "owner",
          "payload",
          "organizationId",
          "workspaceId",
          "createdAt",
          "updatedAt",
          "deletedAt"
        ]
      },
      "ProblemDetails": {
        "type": "object",
        "description": "RFC 9457 problem details returned for API errors.",
        "required": [
          "type",
          "title",
          "status",
          "code"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri-reference",
            "description": "Problem type identifier."
          },
          "title": {
            "type": "string",
            "description": "Short, human-readable error summary."
          },
          "status": {
            "type": "integer",
            "minimum": 400,
            "maximum": 599,
            "description": "HTTP status code."
          },
          "detail": {
            "type": "string",
            "description": "Human-readable detail specific to this occurrence."
          },
          "instance": {
            "type": "string",
            "format": "uri-reference",
            "description": "Identifier for this occurrence."
          },
          "code": {
            "type": "string",
            "description": "Stable machine-readable Replyn error code."
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "Replyn developer documentation",
    "url": "https://replyn.io/docs/settings/developer"
  }
}