openapi: 3.0.0
info:
  version: "2024.08"
  title: Dyspatch API
  description: |
    # Introduction

    The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response
    codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted.
    See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on
    how to implement Dyspatch.

    ## Generating API Clients
    Dyspatch provides OpenAPI specifications for our API which can be used to generate API clients in various programming languages. We recommend using [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator). To download the latest OpenAPI specifications, click the Download button at the top of this page. To download a specific version, view the [changelog](https://docs.dyspatch.io/api/changelog.html/) and select the desired version.
  contact:
    name: Dyspatch Support
    url: https://docs.dyspatch.io
    email: support@dyspatch.io
  termsOfService: https://www.dyspatch.io/legal/terms-of-service/
paths:
  /workspaces:
    get:
      operationId: listWorkspaces
      security:
        - Bearer: []
      summary: List Workspaces
      description: Gets a list of Workspace objects for all workspaces. Up to 25
        results returned before results are paginated.
      tags:
        - Workspaces
      parameters:
        - $ref: "#/components/parameters/cursor"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A list of workspaces
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the time window.
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/WorkspacesRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/workspaces/{folderId}":
    get:
      operationId: listFolder
      security:
        - Bearer: []
      summary: List Folder
      description: Gets a Folder with a list of its sub-folders for the provided id.
      tags:
        - Workspaces
      parameters:
        - $ref: "#/components/parameters/folderId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Folder
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the time window.
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/FolderList"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  /templates:
    get:
      operationId: getTemplates
      security:
        - Bearer: []
      summary: List Templates
      description:
        Gets a list of Template Metadata objects for all published templates. Up to 25
        results returned before results are paginated.
      tags:
        - Templates
      parameters:
        - $ref: "#/components/parameters/cursor"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A list of templates
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the time window.
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/TemplatesRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/templates/{templateId}":
    get:
      operationId: getTemplateById
      security:
        - Bearer: []
      summary: Get Template by ID
      description:
        Gets a template object with the matching ID. Templates without a
        published draft will result in an error.
      tags:
        - Templates
      parameters:
        - $ref: "#/components/parameters/templateId"
        - $ref: "#/components/parameters/targetLanguage"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description:
            A template object with the requested ID. Templates without a
            published draft will result in an error.
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/TemplateRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/render/template/{templateId}":
    post:
      operationId: renderTemplate
      security:
        - Bearer: []
      summary: Render Template by ID
      description: Renders a template into HTML using the provided data.
      tags:
        - Templates
      parameters:
        - $ref: "#/components/parameters/templateId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Rendered template contents incorporating the data passed in the request body.
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/TemplateRender"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/render/template/{templateId}/{languageId}":
    post:
      operationId: renderTemplateByLCID
      security:
        - Bearer: []
      summary: Render Localized Template by ID
      description: Renders a template into HTML for the selected language using the provided data.
      tags:
        - Templates
      parameters:
        - $ref: "#/components/parameters/templateId"
        - $ref: "#/components/parameters/languageId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Rendered template contents in the selected language, incorporating the data passed in the request body.
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/TemplateRender"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/drafts":
    get:
      operationId: getDrafts
      security:
        - Bearer: []
      summary: List Drafts
      description: Returns all Email drafts for your organization.
      tags:
        - Drafts
      parameters:
        - $ref: "#/components/parameters/cursor"
        - $ref: "#/components/parameters/status"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Drafts
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the time window.
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/DraftsRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/drafts/{draftId}/publishRequest":
    post:
      operationId: submitDraftForApproval
      security:
        - Bearer: []
      summary: Submit Draft for Approval
      description: Moves the Email draft into submitted state.
      tags:
        - Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Successfully submitted
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/drafts/{draftId}":
    get:
      operationId: getDraftById
      security:
        - Bearer: []
      summary: Get Draft by ID
      description:
        Gets a Email draft object with the matching ID. The "compiled" field will
        contain the template in the default, unlocalized form.
      tags:
        - Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/targetLanguage"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A draft object with the requested ID.
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/DraftRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/drafts/{draftId}/localizations":
    get:
      operationId: getLocalizationForDraft
      security:
        - Bearer: []
      summary: Get Localizations on a Draft
      description: Returns localization metadata for the Email draft
      tags:
        - Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A list of localizations
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/LocalizationMetaRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
  "/drafts/{draftId}/localizations/{languageId}":
    put:
      operationId: saveLocalization
      security:
        - Bearer: []
      summary: Create or Update a Localization
      description:
        Inserts a localization or sets the name on an existing localization that
        already uses the languageId
      tags:
        - Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/languageId"
        - $ref: "#/components/parameters/version"
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: English (US)
        required: true
      responses:
        "200":
          description: Successful upsert
        "400":
          $ref: "#/components/responses/InvalidRequest"
    delete:
      operationId: deleteLocalization
      security:
        - Bearer: []
      summary: Remove a Localization from Draft
      description: Deletes the localization with the given language ID if it exists
      tags:
        - Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/languageId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Successful delete
        "400":
          $ref: "#/components/responses/InvalidRequest"
  "/drafts/{draftId}/localizations/{languageId}/translations":
    put:
      operationId: setTranslation
      security:
        - Bearer: []
      summary: Set Draft Translations for Language
      description:
        Completely replaces any existing translations for the given language
        with those provided in request body. Variables embedded in keys or
        values are expected to be in the format `%(my_variable)s` and will
        automatically convert to the correct Dyspatch format depending on the
        type of template. Accepts key/value pairs in JSON format or in gettext
        PO file format. For JSON set `Content-Type` header to
        `application/json`. For gettext PO format set `Content-Type` header to
        `text/x-gettext-translation`.
      tags:
        - Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/languageId"
        - $ref: "#/components/parameters/version"
      requestBody:
        content:
          application/json:
            schema:
              type: object
              additionalProperties:
                type: string
              example:
                Hello %(name)s: Bonjour %(name)s
                Welcome: Bienvenue
        required: true
      responses:
        "200":
          description: Successful
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "403":
          $ref: "#/components/responses/Unauthorized"
  "/drafts/{draftId}/localizationKeys":
    get:
      operationId: getDraftLocalizationKeys
      security:
        - Bearer: []
      summary: Get Draft Localization Keys
      description:
        Returns the list of values that need to be translated for the draft. Set
        the `Accept` header to `application/vnd.dyspatch.2024.08+json` to get a
        JSON object, or `text/vnd.dyspatch.2024.08+x-gettext-translation` to get
        the POT file.
      tags:
        - Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Localization keys
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/LocalizationKeyRead"
            text/vnd.dyspatch.2024.08+x-gettext-translation:
              schema:
                type: string
                format: binary
        "400":
          $ref: "#/components/responses/InvalidRequest"
  "/localizations/{localizationId}":
    get:
      operationId: getPublishedLocalizationById
      security:
        - Bearer: []
      summary: Get Localization Object by ID
      description: Returns the published content associated with the localization of the matching ID
      tags:
        - Localizations
      parameters:
        - $ref: "#/components/parameters/localizationId"
        - $ref: "#/components/parameters/targetLanguage"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A localization object with the requested ID
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/LocalizationRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/localizations/{localizationId}/drafts/{draftId}":
    get:
      operationId: getDraftLocalizationById
      security:
        - Bearer: []
      summary: Get Draft Localization Object by ID
      description: Returns a specific localization object of the matching draft with a matching localization ID
      tags:
        - Localizations
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/localizationId"
        - $ref: "#/components/parameters/targetLanguage"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A localization object from the matching draft ID with the requested ID
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/LocalizationRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  /blocks:
    get:
      operationId: getBlocks
      security:
        - Bearer: []
      summary: List Blocks
      description: Gets a list of Blocks
      tags:
        - Blocks
      parameters:
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A list of blocks
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the time window.
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/BlocksRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/blocks/{blockId}":
    get:
      operationId: getBlock
      security:
        - Bearer: []
      summary: Get Block by ID
      description: Gets a block with the matching ID.
      tags:
        - Blocks
      parameters:
        - $ref: "#/components/parameters/version"
        - $ref: "#/components/parameters/blockId"
      responses:
        "200":
          description: A block
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the time window.
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/BlockRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/blocks/{blockId}/localizations":
    get:
      operationId: getLocalizationsForBlock
      security:
        - Bearer: []
      summary: Get localizations on a block
      description: Returns localization metadata for the block
      tags:
        - Blocks
      parameters:
        - $ref: "#/components/parameters/blockId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A list of localizations
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/LocalizationMetaRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/blocks/{blockId}/localizationKeys":
    get:
      operationId: getBlockLocalizationKeys
      security:
        - Bearer: []
      summary: Get localization keys
      description: Returns the list of values that need to be translated for the block.
      tags:
        - Blocks
      parameters:
        - $ref: "#/components/parameters/blockId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Localization keys
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/LocalizationKeyRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/blocks/{blockId}/localizations/{languageId}":
    put:
      operationId: saveBlockLocalization
      security:
        - Bearer: []
      summary: Create or update a block localization
      description:
        Inserts a localization or sets the name on an existing localization that
        already uses the languageId
      tags:
        - Blocks
      parameters:
        - $ref: "#/components/parameters/blockId"
        - $ref: "#/components/parameters/languageId"
        - $ref: "#/components/parameters/version"
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: English (US)
        required: true
      responses:
        "200":
          description: Successful upsert
    delete:
      operationId: deleteBlockLocalization
      security:
        - Bearer: []
      summary: Remove a localization
      description: Deletes the localization with the given language ID if it exists
      tags:
        - Blocks
      parameters:
        - $ref: "#/components/parameters/blockId"
        - $ref: "#/components/parameters/languageId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Successful delete
  "/blocks/{blockId}/localizations/{languageId}/translations":
    put:
      operationId: setBlockTranslations
      security:
        - Bearer: []
      summary: Set translations for language
      description:
        Completely replaces any existing translations for the given language
        with those provided in request body. Variables embedded in keys or
        values are expected to be in the format `%(my_variable)s` and will
        automatically convert to the correct Dyspatch format depending on the
        type of template. Accepts key/value pairs in JSON format.
      tags:
        - Blocks
      parameters:
        - $ref: "#/components/parameters/blockId"
        - $ref: "#/components/parameters/languageId"
        - $ref: "#/components/parameters/version"
      requestBody:
        content:
          application/json:
            schema:
              type: object
              additionalProperties:
                type: string
              example:
                Hello %(name)s: Bonjour %(name)s
                Welcome: Bienvenue
        required: true
      responses:
        "200":
          description: Successful
        "403":
          $ref: "#/components/responses/Unauthorized"
  /sms/templates:
    get:
      operationId: getSMSTemplates
      security:
        - Bearer: []
      summary: List SMS Templates
      description:
        Gets a list of SMS Template Metadata objects for all published templates. Up to 25
        results returned before results are paginated.
      tags:
        - SMS Templates
      parameters:
        - $ref: "#/components/parameters/cursor"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A list of SMS templates
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the time window.
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/TemplatesRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/sms/templates/{templateId}":
    get:
      operationId: getSMSTemplateById
      security:
        - Bearer: []
      summary: Get SMS Template by ID
      description:
        Gets an SMS template object with the matching ID. Templates without a
        published draft will result in an error.
      tags:
        - SMS Templates
      parameters:
        - $ref: "#/components/parameters/templateId"
        - $ref: "#/components/parameters/smsTargetLanguage"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description:
            A template object with the requested ID. Templates without a
            published draft will result in an error.
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/SMSTemplateRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/sms/render/template/{templateId}":
    post:
      operationId: renderSMSTemplate
      security:
        - Bearer: []
      summary: Render SMS Template by ID
      description: Renders an SMS template into HTML using the provided data.
      tags:
        - SMS Templates
      parameters:
        - $ref: "#/components/parameters/templateId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Rendered template contents incorporating the data passed in the request body.
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/SMSTemplateRender"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/sms/render/template/{templateId}/{languageId}":
    post:
      operationId: renderSMSTemplateByLCID
      security:
        - Bearer: []
      summary: Render Localized SMS Template by ID
      description: Renders an SMS template into HTML for the selected language using the provided data.
      tags:
        - SMS Templates
      parameters:
        - $ref: "#/components/parameters/templateId"
        - $ref: "#/components/parameters/languageId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Rendered template contents in the selected language, incorporating the data passed in the request body.
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/SMSTemplateRender"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/sms/drafts":
    get:
      operationId: getSMSDrafts
      security:
        - Bearer: []
      summary: List SMS Drafts
      description: Returns all SMS drafts for your organization.
      tags:
        - SMS Drafts
      parameters:
        - $ref: "#/components/parameters/cursor"
        - $ref: "#/components/parameters/status"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Drafts
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the time window.
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/DraftsRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/sms/drafts/{draftId}/publishRequest":
    post:
      operationId: submitSMSDraftForApproval
      security:
        - Bearer: []
      summary: Submit SMS Draft for Approval
      description: Moves the SMS draft into submitted state.
      tags:
        - SMS Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Successfully submitted
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/sms/drafts/{draftId}":
    get:
      operationId: getSMSDraftById
      security:
        - Bearer: []
      summary: Get SMS Draft by ID
      description:
        Gets an SMS draft object with the matching ID. The "compiled" field will
        contain the template in the default, unlocalized form.
      tags:
        - SMS Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A draft object with the requested ID.
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/SMSDraftRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/sms/drafts/{draftId}/localizations":
    get:
      operationId: getSMSLocalizationForDraft
      security:
        - Bearer: []
      summary: Get Localizations on an SMS Draft
      description: Returns localization metadata for the SMS draft
      tags:
        - SMS Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A list of localizations
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/LocalizationMetaRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
  "/sms/drafts/{draftId}/localizations/{languageId}":
    put:
      operationId: saveSMSLocalization
      security:
        - Bearer: []
      summary: Create or Update an SMS Localization
      description:
        Inserts a localization or sets the name on an existing localization that
        already uses the languageId
      tags:
        - SMS Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/languageId"
        - $ref: "#/components/parameters/version"
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: English (US)
        required: true
      responses:
        "200":
          description: Successful upsert
        "400":
          $ref: "#/components/responses/InvalidRequest"
    delete:
      operationId: deleteSMSLocalization
      security:
        - Bearer: []
      summary: Remove a Localization from SMS Draft
      description: Deletes the localization with the given language ID if it exists
      tags:
        - SMS Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/languageId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Successful delete
        "400":
          $ref: "#/components/responses/InvalidRequest"
  "/sms/drafts/{draftId}/localizations/{languageId}/translations":
    put:
      operationId: setSMSTranslation
      security:
        - Bearer: []
      summary: Set SMS Draft Translations for Language
      description:
        Completely replaces any existing translations for the given language
        with those provided in request body. Variables embedded in keys or
        values are expected to be in the format `%(my_variable)s` and will
        automatically convert to the correct Dyspatch format depending on the
        type of template. Accepts key/value pairs in JSON format or in gettext
        PO file format. For JSON set `Content-Type` header to
        `application/json`. For gettext PO format set `Content-Type` header to
        `text/x-gettext-translation`.
      tags:
        - SMS Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/languageId"
        - $ref: "#/components/parameters/version"
      requestBody:
        content:
          application/json:
            schema:
              type: object
              additionalProperties:
                type: string
              example:
                Hello %(name)s: Bonjour %(name)s
                Welcome: Bienvenue
        required: true
      responses:
        "200":
          description: Successful
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "403":
          $ref: "#/components/responses/Unauthorized"
  "/sms/drafts/{draftId}/localizationKeys":
    get:
      operationId: getSMSDraftLocalizationKeys
      security:
        - Bearer: []
      summary: Get SMS Draft Localization Keys
      description:
        Returns the list of values that need to be translated for the draft. Set
        the `Accept` header to `application/vnd.dyspatch.2024.08+json` to get a
        JSON object, or `text/vnd.dyspatch.2024.08+x-gettext-translation` to get
        the POT file.
      tags:
        - SMS Drafts
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: Localization keys
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/LocalizationKeyRead"
            text/vnd.dyspatch.2024.08+x-gettext-translation:
              schema:
                type: string
                format: binary
        "400":
          $ref: "#/components/responses/InvalidRequest"
  "/sms/localizations/{localizationId}":
    get:
      operationId: getSMSPublishedLocalizationById
      security:
        - Bearer: []
      summary: Get SMS Localization Object by ID
      description: Returns the published SMS content associated with the localization of the matching ID
      tags:
        - SMS Localizations
      parameters:
        - $ref: "#/components/parameters/localizationId"
        - $ref: "#/components/parameters/smsTargetLanguage"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A localization object with the requested ID
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/SMSLocalizationRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
  "/sms/localizations/{localizationId}/drafts/{draftId}":
    get:
      operationId: getSMSDraftLocalizationById
      security:
        - Bearer: []
      summary: Get SMS Draft Localization Object by ID
      description: Returns a specific localization object of the matching SMS draft with a matching localization ID
      tags:
        - SMS Localizations
      parameters:
        - $ref: "#/components/parameters/draftId"
        - $ref: "#/components/parameters/localizationId"
        - $ref: "#/components/parameters/smsTargetLanguage"
        - $ref: "#/components/parameters/version"
      responses:
        "200":
          description: A localization object from the matching draft ID with the requested ID
          headers:
            X-RateLimit-Remaining:
              description: The number of requests left for the current time window
              schema:
                type: integer
          content:
            application/vnd.dyspatch.2024.08+json:
              schema:
                $ref: "#/components/schemas/SMSLocalizationRead"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthenticated"
        "403":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        default:
          $ref: "#/components/responses/InternalError"
tags:
  - name: Templates
    description: |
      Templates are the email templates found in your Dyspatch account. Only the
      published Template Draft is returned.

      A typical integration will start with using the Templates list endpoint to iterate through and sync Templates.
  - name: Drafts
    description: >
      Drafts represent unpublished versions of templates that are still mutable.
      There could be many in progress drafts for a template.
  - name: Localizations
    description: |
      Localization objects are the same as Template objects except they contain
      localized content.

      If your account is using localizations then use this instead of the compiled Template object.
  - name: SMS Templates
    description: |
      SMS Templates are the SMS templates found in your Dyspatch account. Only the
      published Template Draft is returned.

      A typical integration will start with using the Templates list endpoint to iterate through and sync Templates.
  - name: SMS Drafts
    description: >
      SMS Drafts represent unpublished versions of templates that are still mutable.
      There could be many in progress drafts for a template.
  - name: SMS Localizations
    description: |
      SMS Localization objects are the same as Template objects except they contain
      localized content.

      If your account is using localizations then use this instead of the compiled Template object.
servers:
  - url: https://api.dyspatch.io
components:
  parameters:
    version:
      in: header
      name: Accept
      required: true
      description:
        A version of the API that should be used for the request. For example,
        to use version "2024.08", set the value to
        "application/vnd.dyspatch.2024.08+json"
      schema:
        type: string
    cursor:
      name: cursor
      in: query
      description:
        A cursor value used to retrieve a specific page from a paginated result
        set.
      required: false
      schema:
        type: string
    folderId:
      name: folderId
      in: path
      description: A workspace/folder ID
      required: true
      schema:
        type: string
    templateId:
      name: templateId
      in: path
      description: A template ID
      required: true
      schema:
        type: string
    draftId:
      name: draftId
      in: path
      description: A draft ID
      required: true
      schema:
        type: string
    languageId:
      name: languageId
      in: path
      description: "A language ID (eg: en-US)"
      required: true
      schema:
        type: string
    targetLanguage:
      name: targetLanguage
      in: query
      description:
        The type of templating language to compile as. Should only be used for
        visual templates.
      required: true
      schema:
        type: string
        enum:
          - html
          - handlebars
          - ampscript
          - freemarker
          - cheetah
          - jinja
          - liquid
          - mandrillhandlebars
          - handlebarsjava
    smsTargetLanguage:
      name: targetLanguage
      in: query
      description:
        The type of templating language to compile as. Should only be used for
        visual templates.
      required: false
      schema:
        type: string
        enum:
          - sms
    localizationId:
      name: localizationId
      in: path
      description: A localization ID
      required: true
      schema:
        type: string
    status:
      name: status
      in: query
      description: Filter the list of drafts by a particular status
      required: false
      schema:
        type: string
        enum:
          - awaitingTranslation
    blockId:
      name: blockId
      in: path
      description: A block ID
      required: true
      schema:
        type: string
  responses:
    InternalError:
      description: Server error
      headers:
        X-RateLimit-Remaining:
          description: The number of requests left for the time window.
          schema:
            type: integer
      content:
        "*/*":
          schema:
            $ref: "#/components/schemas/APIError"
    InvalidRequest:
      description: Invalid request
      headers:
        X-RateLimit-Remaining:
          description: The number of requests left for the time window.
          schema:
            type: integer
      content:
        "*/*":
          schema:
            $ref: "#/components/schemas/APIError"
    RateLimited:
      description: Rate limit exceeded
      headers:
        X-RateLimit-Remaining:
          description: The number of requests left for the time window.
          schema:
            type: integer
      content:
        "*/*":
          schema:
            $ref: "#/components/schemas/APIError"
    Unauthenticated:
      description: Unauthenticated
      headers:
        X-RateLimit-Remaining:
          description: The number of requests left for the time window.
          schema:
            type: integer
      content:
        "*/*":
          schema:
            $ref: "#/components/schemas/APIError"
    Unauthorized:
      description: Unauthorized
      headers:
        X-RateLimit-Remaining:
          description: The number of requests left for the time window.
          schema:
            type: integer
      content:
        "*/*":
          schema:
            $ref: "#/components/schemas/APIError"
    NotFound:
      description: Resource not found
      headers:
        X-RateLimit-Remaining:
          description: The number of requests left for the time window.
          schema:
            type: integer
      content:
        "*/*":
          schema:
            $ref: "#/components/schemas/APIError"
  securitySchemes:
    Bearer:
      type: apiKey
      name: Authorization
      in: header
      description: |
        Set Bearer followed by your API key as the Authorization header in your
        API requests.

        ```shell
        Authorization: Bearer EXAMPLEAPIKEYXXXXXXXX12345678
        ```

        Below is an example curl request with an API key in the Authorization header.

        ```shell
        curl --request GET \
        --url https://api.dyspatch.io/templates \
        --header 'Authorization: Bearer EXAMPLEAPIKEYXXXXXXXX12345678' \
        --header 'Accept: application/vnd.dyspatch.2024.08+json'
        ```
  schemas:
    cursor:
      type: object
      description: Information about paginated results
      properties:
        next:
          type: string
          description: A cursor to fetch the next page of results
        hasMore:
          type: boolean
          description: Whether there is a next page of results
    folderId:
      type: string
      description: A workspace/folder ID
      example: fdr_01g0z4d5aw
    folderName:
      type: string
      description: The name of a workspace/folder
      example: Name of Folder
    folderDescription:
      type: string
      description: A description of the workspace/folder
      example: Description of Folder
    folderUrl:
      type: string
      example: /workspaces/fdr_g3L7Cw6Hp5wUaf395LehwK
      description: The API url for a specific template
    templateId:
      type: string
      description: An opaque, unique identifier for a template
      example: tem_g3L7Cw6Hp5wU
    draftId:
      type: string
      description: An opaque, unique identifier for a draft
      example: tdft_g3L7Cw6Hp5wU
    localeGroupId:
      description: the locale group this localization belongs to, if this field is empty the localization does not belong to any locale group
      type: string
      example: lgr_alka38ajla301
    templateName:
      type: string
      description: The name of a template
      example: Template Name
    templateDescription:
      type: string
      description: A description of the template
      example: Description of Template
    templateUrl:
      type: string
      example: /templates/tem_g3L7Cw6Hp5wUaf395LehwK
      description: The API url for a specific template
    draftName:
      type: string
      description: The name of a draft
      example: Draft Name
    path:
      type: string
      description: The folder path location for this object
      example: fdr_01gb8vd6pz/fdr_01gqjmdbq/fdr_01gqjmg1
    workspaceId:
      type: string
      description: The workspace this object belongs to
      example: fdr_01gb8vd6pz
    draftUrl:
      type: string
      example: /drafts/tdft_g3L7Cw6Hp5wUaf395LehwK/dft_g3L7Cw6Hp5wU
      description: The API url for a specific draft
    localizationId:
      type: string
      description: An opaque, unique identifier for a localization
      example: loc_g3L7Cw6Hp5wUaf395LehwK
    localizationUrl:
      type: string
      example: /localizations/loc_g3L7Cw6Hp5wUaf395LehwK
      description: The API url for a specific localization
    localizationName:
      type: string
      example: English (US)
      description: The user-specified name of a localization
    languages:
      type: array
      items:
        type: string
        example: fr-FR
      description: >
        a list of locale codes that are available in the localization.
        See [supported languages](https://docs.dyspatch.io/localization/supported_languages/)
        for an exhaustive list of locale codes.
    createdAt:
      type: string
      format: date-time
      description: The time of initial creation
    updatedAt:
      type: string
      format: date-time
      description: The time of last update
    status:
      type: string
      example: "LOCKED_FOR_TRANSLATION"
      description: >
        The status of the current draft. States include: "IN_PROGRESS", "PENDING_APPROVAL", "LOCKED_FOR_TRANSLATION"
    designApprovedDate:
      type: string
      format: date-time
      description: >
        If using the design approval workflow this is the date the template draft design was approved, otherwise it will be empty.
    blockId:
      type: string
      description: An opaque, unique identifier for a block
      example: blk_01gpe172x7p6aa1c9grr48efq8
    blockName:
      type: string
      example: Header Block
      description: The user-specified name of a block
    blockDescription:
      type: string
      description: The user-specified description of a block
    blockUrl:
      type: string
      example: /blocks/blk_01gpe172x7p6aa1c9grr48efq8
      description: The API url for a specific block
    TemplateMetaRead:
      type: object
      description: the template metadata
      properties:
        id:
          $ref: "#/components/schemas/templateId"
        name:
          $ref: "#/components/schemas/templateName"
        description:
          $ref: "#/components/schemas/templateDescription"
        url:
          $ref: "#/components/schemas/templateUrl"
        path:
          $ref: "#/components/schemas/path"
        workspaceId:
          $ref: "#/components/schemas/workspaceId"
        localizations:
          type: array
          items:
            $ref: "#/components/schemas/LocalizationMetaRead"
          description: A list of the template's available localization objects
        createdAt:
          $ref: "#/components/schemas/createdAt"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
        publishedDraftId:
          $ref: "#/components/schemas/draftId"
    WorkspacesRead:
      type: object
      description: list of workspaces
      properties:
        cursor:
          $ref: "#/components/schemas/cursor"
        data:
          type: array
          items:
            $ref: "#/components/schemas/FolderRead"
          description: A list of workspace objects
    FolderList:
      type: object
      description: folder with a list of its sub-folders
      properties:
        id:
          $ref: "#/components/schemas/folderId"
        name:
          $ref: "#/components/schemas/folderName"
        description:
          $ref: "#/components/schemas/folderDescription"
        url:
          $ref: "#/components/schemas/folderUrl"
        createdAt:
          $ref: "#/components/schemas/createdAt"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
        subfolders:
          type: array
          items:
            $ref: "#/components/schemas/FolderRead"
          description: A list of sub-folder objects
    FolderRead:
      type: object
      description: list of template metadata
      properties:
        id:
          $ref: "#/components/schemas/folderId"
        name:
          $ref: "#/components/schemas/folderName"
        description:
          $ref: "#/components/schemas/folderDescription"
        url:
          $ref: "#/components/schemas/folderUrl"
        createdAt:
          $ref: "#/components/schemas/createdAt"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
    TemplatesRead:
      type: object
      description: list of template metadata
      properties:
        cursor:
          $ref: "#/components/schemas/cursor"
        data:
          type: array
          items:
            $ref: "#/components/schemas/TemplateMetaRead"
          description: A list of template metadata objects
    TemplateRead:
      type: object
      description: list of template metadata
      properties:
        id:
          $ref: "#/components/schemas/templateId"
        name:
          $ref: "#/components/schemas/templateName"
        description:
          $ref: "#/components/schemas/templateDescription"
        url:
          $ref: "#/components/schemas/templateUrl"
        compiled:
          $ref: "#/components/schemas/CompiledRead"
        path:
          $ref: "#/components/schemas/path"
        workspaceId:
          $ref: "#/components/schemas/workspaceId"
        createdAt:
          $ref: "#/components/schemas/createdAt"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
        publishedDraftId:
          $ref: "#/components/schemas/draftId"
        localizations:
          type: array
          items:
            $ref: "#/components/schemas/LocalizationMetaRead"
          description: A list of the Template's available localizations
    SMSTemplateRead:
      type: object
      description: list of template metadata
      properties:
        id:
          $ref: "#/components/schemas/templateId"
        name:
          $ref: "#/components/schemas/templateName"
        description:
          $ref: "#/components/schemas/templateDescription"
        url:
          $ref: "#/components/schemas/templateUrl"
        compiled:
          $ref: "#/components/schemas/SMSCompiledRead"
        path:
          $ref: "#/components/schemas/path"
        workspaceId:
          $ref: "#/components/schemas/workspaceId"
        createdAt:
          $ref: "#/components/schemas/createdAt"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
        publishedDraftId:
          $ref: "#/components/schemas/draftId"
        localizations:
          type: array
          items:
            $ref: "#/components/schemas/LocalizationMetaRead"
          description: A list of the Template's available localizations
    DraftRead:
      type: object
      description: template draft metadata included latest draft revision
      properties:
        id:
          $ref: "#/components/schemas/draftId"
        template:
          $ref: "#/components/schemas/templateId"
        name:
          $ref: "#/components/schemas/draftName"
        url:
          $ref: "#/components/schemas/draftUrl"
        path:
          $ref: "#/components/schemas/path"
        workspaceId:
          $ref: "#/components/schemas/workspaceId"
        compiled:
          $ref: "#/components/schemas/CompiledRead"
        createdAt:
          $ref: "#/components/schemas/createdAt"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
        localizations:
          type: array
          items:
            $ref: "#/components/schemas/LocalizationMetaRead"
          description: A list of the Template's available localizations
        status:
          $ref: "#/components/schemas/status"
        templateName:
          $ref: "#/components/schemas/templateName"
        designApprovedDate:
          $ref: "#/components/schemas/designApprovedDate"
    SMSDraftRead:
      type: object
      description: template draft metadata included latest draft revision
      properties:
        id:
          $ref: "#/components/schemas/draftId"
        template:
          $ref: "#/components/schemas/templateId"
        name:
          $ref: "#/components/schemas/draftName"
        url:
          $ref: "#/components/schemas/draftUrl"
        path:
          $ref: "#/components/schemas/path"
        workspaceId:
          $ref: "#/components/schemas/workspaceId"
        compiled:
          $ref: "#/components/schemas/SMSCompiledRead"
        createdAt:
          $ref: "#/components/schemas/createdAt"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
        localizations:
          type: array
          items:
            $ref: "#/components/schemas/LocalizationMetaRead"
          description: A list of the Template's available localizations
        status:
          $ref: "#/components/schemas/status"
        templateName:
          $ref: "#/components/schemas/templateName"
        designApprovedDate:
          $ref: "#/components/schemas/designApprovedDate"
    LocalizationMetaRead:
      type: object
      description: localization metadata
      properties:
        id:
          $ref: "#/components/schemas/localizationId"
        name:
          $ref: "#/components/schemas/localizationName"
        url:
          $ref: "#/components/schemas/localizationUrl"
        localeGroup:
          $ref: "#/components/schemas/localeGroupId"
        languages:
          $ref: "#/components/schemas/languages"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
    LocalizationRead:
      type: object
      description: localization metadata and latest revision for associated template
      properties:
        id:
          $ref: "#/components/schemas/localizationId"
        languages:
          $ref: "#/components/schemas/languages"
        url:
          $ref: "#/components/schemas/localizationUrl"
        template:
          $ref: "#/components/schemas/templateId"
        compiled:
          $ref: "#/components/schemas/CompiledRead"
        createdAt:
          $ref: "#/components/schemas/createdAt"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
        name:
          $ref: "#/components/schemas/localizationName"
        localeGroup:
          $ref: "#/components/schemas/localeGroupId"
    SMSLocalizationRead:
      type: object
      description: localization metadata and latest revision for associated template
      properties:
        id:
          $ref: "#/components/schemas/localizationId"
        languages:
          $ref: "#/components/schemas/languages"
        url:
          $ref: "#/components/schemas/localizationUrl"
        template:
          $ref: "#/components/schemas/templateId"
        compiled:
          $ref: "#/components/schemas/SMSCompiledRead"
        createdAt:
          $ref: "#/components/schemas/createdAt"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
        name:
          $ref: "#/components/schemas/localizationName"
        localeGroup:
          $ref: "#/components/schemas/localeGroupId"
    LocalizationKeyRead:
      type: object
      description: localization key
      properties:
        key:
          type: string
        comment:
          type: string
    DraftsRead:
      type: object
      description: list of draft metadata
      properties:
        cursor:
          $ref: "#/components/schemas/cursor"
        data:
          type: array
          items:
            $ref: "#/components/schemas/DraftMetaRead"
          description: A list of draft metadata objects
    DraftMetaRead:
      type: object
      description: draft metadata
      properties:
        id:
          $ref: "#/components/schemas/draftId"
        templateId:
          $ref: "#/components/schemas/templateId"
        name:
          $ref: "#/components/schemas/draftName"
        url:
          $ref: "#/components/schemas/draftUrl"
        path:
          $ref: "#/components/schemas/path"
        workspaceId:
          $ref: "#/components/schemas/workspaceId"
        createdAt:
          $ref: "#/components/schemas/createdAt"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
        status:
          $ref: "#/components/schemas/status"
        templateName:
          $ref: "#/components/schemas/templateName"
        designApprovedDate:
          $ref: "#/components/schemas/designApprovedDate"
    APIError:
      type: object
      description: possible errors from the api
      properties:
        code:
          type: string
          enum:
            - server_error
            - invalid_parameter
            - invalid_body
            - invalid_request
            - unauthorized
            - unauthenticated
            - not_found
            - rate_limited
            - prohibited_action
          description: |
            Error code:
              * server_error - Internal server error.
              * invalid_parameter - Validation error, parameter will contain invalid field and message will contain the reason.
              * invalid_body - Body could not be parsed, message will contain the reason.
              * invalid_request - Validation error, the protocol used to make the request was not https.
              * unauthorized - Credentials were found but permissions were not sufficient.
              * unauthenticated - Credentials were not found or were not valid.
              * not_found - The requested resource was not found.
              * rate_limited - The request was refused because a rate limit was exceeded. There is an account wide rate limit of 3600 requests per-minute, although that is subject to change. The current remaining rate limit can be viewed by checking the X-Ratelimit-Remaining header.
              * prohibited_action - The request was refused because an action was not valid for the requested resource. Typically this will happen if you try to make changes to a locked resource.
        message:
          type: string
          description: Human readable error message
        parameter:
          type: string
          description: The invalid parameter, if 'code' is invalid_parameter
    CompiledRead:
      type: object
      description: revision data
      properties:
        sender:
          type: string
          example: example@example.com
          description: Sender address
        replyTo:
          type: string
          example: example@example.com
          description: Reply-To address
        subject:
          type: string
          format: byte
          example: PGh0bWw+PC9odG1sPgo=
          description: Base64 encoded template subject line
        html:
          type: string
          format: byte
          example: PGh0bWw+PC9odG1sPgo=
          description: Base64 encoded template HTML body
        ampHtml:
          type: string
          format: byte
          example: PGh0bWwg4pqhNGVtYWlsPjwvaHRtbD4=
          description: Base64 encoded template AMP body
        text:
          type: string
          format: byte
          example: dGV4dCBjb250ZW50
          description: Base64 encoded template text body
    SMSCompiledRead:
      type: object
      description: revision data
      properties:
        sender:
          type: string
          example: John Doe
          description: Sender name
        phone:
          type: string
          example: 123-456-7890
          description: Sender phone number
        content:
          type: array
          items:
            $ref: "#/components/schemas/SMSContent"
    SMSContent:
      type: object
      description: sms draft content
      properties:
        type:
          type: string
          example: Text
          description: What type of content this contains (text or image)
        value:
          type: string
          example: This is some text
          description: The value of the content
    TemplateRender:
      type: object
      description: rendered template with data
      properties:
        html:
          type: string
          description: Rendered HTML template body
          example: <html>Hello, world!<html>
        ampHtml:
          type: string
          description: Rendered AMP HTML template body
          example: <html ⚡4email>Hello, world!<html>
        text:
          type: string
          example: "Hello, world!"
          description: Rendered template text body
        subject:
          type: string
          example: "Email Subject Line"
          description: Template subject line
        sender:
          type: string
          example: example@example.com
          description: Sender address
        replyTo:
          type: string
          example: example@example.com
          description: Reply-To address
    SMSTemplateRender:
      type: object
      description: rendered template with data
      properties:
        sender:
          type: string
          example: John Doe
          description: Sender name
        phone:
          type: string
          example: 123-456-7890
          description: Sender phone number
        content:
          type: array
          items:
            $ref: "#/components/schemas/SMSContent"
    BlocksRead:
      type: object
      description: list of blocks
      properties:
        cursor:
          $ref: "#/components/schemas/cursor"
        data:
          type: array
          items:
            $ref: "#/components/schemas/BlockRead"
          description: A list of block objects
    BlockRead:
      type: object
      description: block data
      properties:
        id:
          $ref: "#/components/schemas/blockId"
        name:
          $ref: "#/components/schemas/blockName"
        description:
          $ref: "#/components/schemas/blockDescription"
        createdAt:
          $ref: "#/components/schemas/createdAt"
        updatedAt:
          $ref: "#/components/schemas/updatedAt"
        url:
          $ref: "#/components/schemas/blockUrl"
