{
  "openapi": "3.1.0",
  "info": {
    "title": "Oblic API",
    "description": "Journeys, segments and messages, for the user and workspace an OAuth access token names. Request the token for the resource https://api.oblic.app/external/v2. Every token reads; sending also needs the send scope, and a role that sends in the organization's default workspace. Only a server or a native app can hold a token: no browser origin is allowed.",
    "version": "2"
  },
  "servers": [
    {
      "url": "https://api.oblic.app"
    }
  ],
  "security": [
    {
      "workspaceToken": [
        "read"
      ]
    }
  ],
  "tags": [
    {
      "name": "Segments",
      "description": "The workspace's lists and dynamic segments"
    },
    {
      "name": "Messages",
      "description": "Send email, SMS and WhatsApp, and see what became of each"
    },
    {
      "name": "Journeys",
      "description": "The workspace's campaigns, automations and WhatsApp bots, and the journeys built in Journeys itself"
    }
  ],
  "paths": {
    "/external/v2/messages/whatsapp": {
      "post": {
        "tags": [
          "Messages"
        ],
        "summary": "Send an approved WhatsApp template, or a reply within 24 hours",
        "operationId": "sendWhatsApp",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalWhatsAppRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Queued: the message's id and status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Out"
                }
              }
            }
          },
          "402": {
            "description": "INSUFFICIENT_BALANCE: a marketing message, and the wallet that pays for the account is empty. Nothing was queued or charged; sign-in codes, transactional messages and replies are never refused for the wallet.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Out"
                }
              }
            }
          }
        },
        "security": [
          {
            "workspaceToken": [
              "send"
            ]
          }
        ]
      }
    },
    "/external/v2/messages/sms": {
      "post": {
        "tags": [
          "Messages"
        ],
        "summary": "Send an SMS that matches one of the account's DLT templates",
        "operationId": "sendSms",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalSmsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Queued: the message's id and status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Out"
                }
              }
            }
          },
          "402": {
            "description": "INSUFFICIENT_BALANCE: a marketing message, and the wallet that pays for the account is empty. Nothing was queued or charged; sign-in codes, transactional messages and replies are never refused for the wallet.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Out"
                }
              }
            }
          }
        },
        "security": [
          {
            "workspaceToken": [
              "send"
            ]
          }
        ]
      }
    },
    "/external/v2/messages/email": {
      "post": {
        "tags": [
          "Messages"
        ],
        "summary": "Send an email from a verified sender",
        "operationId": "sendEmail",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Queued: the message's id and status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Out"
                }
              }
            }
          }
        },
        "security": [
          {
            "workspaceToken": [
              "send"
            ]
          }
        ]
      }
    },
    "/external/v2/segments": {
      "get": {
        "tags": [
          "Segments"
        ],
        "summary": "The workspace's lists and dynamic segments",
        "operationId": "listSegments",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Out"
                }
              }
            }
          }
        }
      }
    },
    "/external/v2/segments/{id}": {
      "get": {
        "tags": [
          "Segments"
        ],
        "summary": "One of the workspace's segments",
        "operationId": "getSegment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Out"
                }
              }
            }
          }
        }
      }
    },
    "/external/v2/messages": {
      "get": {
        "tags": [
          "Messages"
        ],
        "summary": "The messages sent through the API, newest first and one per recipient",
        "operationId": "listMessages",
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "[0-9]{1,15}~[A-Za-z0-9]{18}"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 25,
              "maximum": 100,
              "minimum": 1
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "pattern": "email|sms|whatsapp"
              }
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "pattern": "queued|sent|delivered|read|bounced|skipped|failed"
              }
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Out"
                }
              }
            }
          }
        }
      }
    },
    "/external/v2/messages/{messageId}": {
      "get": {
        "tags": [
          "Messages"
        ],
        "summary": "A message sent through the API, and its outcome",
        "operationId": "getMessage",
        "parameters": [
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Out"
                }
              }
            }
          }
        }
      }
    },
    "/external/v2/journeys": {
      "get": {
        "tags": [
          "Journeys"
        ],
        "summary": "A page of the workspace's journeys",
        "operationId": "listJourneys",
        "parameters": [
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 50
            }
          },
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Out"
                }
              }
            }
          }
        }
      }
    },
    "/external/v2/journeys/{id}": {
      "get": {
        "tags": [
          "Journeys"
        ],
        "summary": "One of the workspace's journeys",
        "operationId": "getJourney",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Out"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ExternalWhatsAppRequest": {
        "type": "object",
        "properties": {
          "to": {
            "type": "string",
            "minLength": 1
          },
          "template": {
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "variables": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 1024,
              "minLength": 0
            },
            "maxItems": 30,
            "minItems": 0
          },
          "headerVariables": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 1024,
              "minLength": 0
            },
            "maxItems": 5,
            "minItems": 0
          },
          "headerMediaUrl": {
            "type": "string",
            "maxLength": 2048,
            "minLength": 0
          },
          "text": {
            "type": "string",
            "maxLength": 4096,
            "minLength": 0
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "required": [
          "to"
        ]
      },
      "Out": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string"
          },
          "data": {},
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/errors"
            }
          }
        }
      },
      "errors": {
        "type": "object",
        "properties": {
          "cd": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ExternalSmsRequest": {
        "type": "object",
        "properties": {
          "to": {
            "type": "string",
            "maxLength": 20,
            "minLength": 0
          },
          "text": {
            "type": "string",
            "maxLength": 2000,
            "minLength": 0
          },
          "templateId": {
            "type": "string",
            "pattern": "\\d{1,32}"
          },
          "variables": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 30,
            "minItems": 0
          },
          "senderId": {
            "type": "string",
            "maxLength": 11,
            "minLength": 0
          },
          "purpose": {
            "type": "string",
            "pattern": "otp|transactional|promotional"
          },
          "unicode": {
            "type": "boolean"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "required": [
          "to"
        ]
      },
      "Attachment": {
        "type": "object",
        "properties": {
          "fileName": {
            "type": "string",
            "maxLength": 255,
            "minLength": 0,
            "pattern": "[^/\\\\\"\\r\\n]*"
          },
          "content": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "content",
          "fileName"
        ]
      },
      "ExternalEmailRequest": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "format": "email",
            "maxLength": 255,
            "minLength": 0
          },
          "fromName": {
            "type": "string",
            "maxLength": 255,
            "minLength": 0,
            "pattern": "[^<>\"\\r\\n]*"
          },
          "to": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email",
              "minLength": 1
            },
            "maxItems": 50,
            "minItems": 0
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email",
              "minLength": 1
            },
            "maxItems": 50,
            "minItems": 0
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email",
              "minLength": 1
            },
            "maxItems": 50,
            "minItems": 0
          },
          "replyTo": {
            "type": "string",
            "format": "email"
          },
          "subject": {
            "type": "string",
            "maxLength": 1023,
            "minLength": 0
          },
          "html": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            },
            "maxItems": 10,
            "minItems": 0
          },
          "templateId": {
            "type": "string",
            "pattern": "[A-Za-z0-9]{18}"
          },
          "variables": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "workspaceToken": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://api.oblic.app/oauth2/authorize",
            "tokenUrl": "https://api.oblic.app/oauth2/token",
            "refreshUrl": "https://api.oblic.app/oauth2/token",
            "scopes": {
              "read": "Read the workspace",
              "send": "Send messages at once, as the organization"
            }
          }
        }
      }
    }
  }
}
