---
openapi: 3.0.1
info:
  title: API V1
  version: v1
paths:
  "/api/v1/organizations/{id}":
    patch:
      summary: Update Organization
      tags:
      - Organizations
      description: Updates an organization.
      operationId: updateOrganization
      parameters:
      - name: id
        in: path
        description: Organization ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: Example Inc.
                email:
                  type: string
                  example: john.lennon@beatles.com
                country:
                  type: string
                  example: US
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Organization"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/projects":
    get:
      summary: List Projects
      tags:
      - Projects
      description: Retrieves the projects the user has access to.
      operationId: getProjects
      parameters:
      - "$ref": "#/components/parameters/per"
      - "$ref": "#/components/parameters/page"
      - name: search
        in: query
        description: Filter projects by name
        required: false
        schema:
          type: string
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ProjectList"
    post:
      summary: Creates a project.
      tags:
      - Projects
      description: Creates a new project.
      operationId: createProject
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Project name
                  example: Black Friday 2020
                description:
                  type: string
                  nullable: true
                  description: Project description
                  example: All emails related to Black Friday 2020.
              required:
              - name
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Project"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/projects/{id}":
    get:
      summary: Get Project
      tags:
      - Projects
      description: Retrieves a single project by ID.
      operationId: getProject
      parameters:
      - name: id
        in: path
        description: Project ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Project"
    patch:
      summary: Update Project
      tags:
      - Projects
      description: Updates a project.
      operationId: updateProject
      parameters:
      - name: id
        in: path
        description: Project ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Project name
                  example: Black Friday 2020
                description:
                  type: string
                  nullable: true
                  description: Project description
                  example: All emails related to Black Friday 2020.
              required:
              - name
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Project"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
    delete:
      summary: Delete Project
      tags:
      - Projects
      description: Deletes a project.
      operationId: deleteProject
      parameters:
      - name: id
        in: path
        description: Project ID
        required: true
        schema:
          type: integer
      responses:
        '204':
          description: successful
  "/api/v1/projects/{id}/users":
    get:
      summary: List Project Users
      tags:
      - Project Users
      description: Retrieves the users for a project.
      operationId: getProjectUsers
      parameters:
      - name: id
        in: path
        description: Project ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/UserList"
    patch:
      summary: Update Project Users
      tags:
      - Project Users
      description: Updates the users for a project.
      operationId: updateProjectUsers
      parameters:
      - name: id
        in: path
        description: Project ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                user_ids:
                  type: array
                  items:
                    type: integer
              required:
              - user_ids
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/UserList"
        '422':
          "$ref": "#/components/responses/ValidationError"
  "/api/v1/emails":
    get:
      summary: List Emails
      tags:
      - Emails
      description: Retrieves the Emails the user has access to.
      operationId: getEmails
      parameters:
      - "$ref": "#/components/parameters/per"
      - "$ref": "#/components/parameters/page"
      - name: project_id
        in: query
        description: Filter emails by project ID
        required: false
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/EmailList"
    post:
      summary: Create Email
      tags:
      - Emails
      description: Creates a new Email.
      operationId: createEmail
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                email_design_system_id:
                  type: integer
                default_locale:
                  "$ref": "#/components/schemas/Locale"
                locales:
                  type: array
                  items:
                    "$ref": "#/components/schemas/Locale"
                project_id:
                  type: integer
                create_with_ai:
                  type: boolean
                ai_agent_id:
                  type: integer
                prompt:
                  type: string
              required:
              - name
              - email_design_system_id
              - project_id
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Email"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/emails/{id}":
    get:
      summary: Get Email
      tags:
      - Emails
      description: Retrieves an email by ID.
      operationId: getEmail
      parameters:
      - name: id
        in: path
        description: Email ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Email"
    patch:
      summary: Update Email
      tags:
      - Emails
      description: Updates an email.
      operationId: updateEmail
      parameters:
      - name: id
        in: path
        description: Email ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                email_content:
                  "$ref": "#/components/schemas/EmailContent"
                default_locale:
                  "$ref": "#/components/schemas/Locale"
                locales:
                  type: array
                  items:
                    "$ref": "#/components/schemas/Locale"
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Email"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
    delete:
      summary: Delete Email
      tags:
      - Emails
      description: Deletes an email.
      operationId: deleteEmail
      parameters:
      - name: id
        in: path
        description: Email ID
        required: true
        schema:
          type: integer
      responses:
        '204':
          description: successful
  "/api/v1/emails/{id}/email_translations":
    post:
      summary: Create Email Translation
      tags:
      - Emails
      description: Creates a new Email Translation.
      operationId: createEmailTranslation
      parameters:
      - name: id
        in: path
        description: Email ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                target_locales:
                  type: array
                  items:
                    type: string
              required:
              - target_locales
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/EmailTranslation"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/emails/{id}/email_translations/{email_translation_id}":
    get:
      summary: Get Email Translation
      tags:
      - Emails
      description: Retrieves an email translation.
      operationId: getEmailTranslation
      parameters:
      - name: id
        in: path
        description: Email ID
        required: true
        schema:
          type: integer
      - name: email_translation_id
        in: path
        description: Email Translation ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/EmailTranslation"
        '404':
          "$ref": "#/components/responses/NotFound"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/emails/{id}/translation_spreadsheets":
    get:
      summary: Get Email translation spreadsheet
      tags:
      - Emails
      description: Retrieves the content CSV for an email.
      operationId: getEmailTranslationSpreadsheet
      parameters:
      - name: id
        in: path
        description: Email ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/csv:
              schema:
                type: string
                example: |-
                  locale,content
                  en,Hello
                  fr,Bonjour
                description: The content CSV for the email.
        '404':
          "$ref": "#/components/responses/NotFound"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
    post:
      summary: Upload Email Translation Spreadsheet
      tags:
      - Emails
      description: Uploads a CSV file to update an email translation.
      operationId: uploadEmailTranslationSpreadsheet
      parameters:
      - name: id
        in: path
        description: Email ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                csv_file:
                  type: string
                  format: binary
              required:
              - csv_file
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Email"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/exports":
    get:
      summary: List Exports
      tags:
      - Exports
      description: Retrieves the exports.
      operationId: getExports
      parameters:
      - "$ref": "#/components/parameters/per"
      - "$ref": "#/components/parameters/page"
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ExportList"
    post:
      summary: Create Export
      tags:
      - Exports
      description: Creates a new export.
      operationId: createExport
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                connector_id:
                  type: integer
                  nullable: true
                email_id:
                  type: integer
                export_type:
                  type: string
                  enum:
                  - html
                  - connector
                  - json
                dynamic_content_profile_id:
                  type: string
                  nullable: true
                options:
                  "$ref": "#/components/schemas/ExportOptions"
              required:
              - email_id
              - export_type
              - options
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Export"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/exports/{id}":
    get:
      summary: Get Export
      tags:
      - Exports
      description: Retrieves an export.
      operationId: getExport
      parameters:
      - name: id
        in: path
        description: Export ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Export"
  "/api/v1/email_design_systems":
    get:
      summary: List Email Design Systems
      tags:
      - Email Design Systems
      description: Retrieves the email design systems for the currently logged in
        user.
      operationId: getEmailDesignSystems
      parameters:
      - "$ref": "#/components/parameters/per"
      - "$ref": "#/components/parameters/page"
      - name: archived
        in: query
        description: |
          Filter projects by archive status:
          - `false` (default): Only return non-archived projects
          - `true`: Only return archived projects
          - `all`: Return both archived and non-archived projects
        required: false
        schema:
          type: string
          enum:
          - 'true'
          - 'false'
          - all
          default: false
          example: false
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/EmailDesignSystemList"
    post:
      summary: Create Email Design System
      tags:
      - Email Design Systems
      description: Creates a new email design system.
      operationId: createEmailDesignSystem
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  type: string
                  nullable: true
              required:
              - name
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/EmailDesignSystem"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/email_design_systems/{id}":
    get:
      summary: Get Email Design System
      tags:
      - Email Design Systems
      description: Retrieves an email design system.
      operationId: getEmailDesignSystem
      parameters:
      - name: id
        in: path
        description: Email Design System ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/EmailDesignSystem"
    patch:
      summary: Update Email Design System
      tags:
      - Email Design Systems
      description: Updates an email design system.
      operationId: updateEmailDesignSystem
      parameters:
      - name: id
        in: path
        description: Email Design System ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  type: string
                  nullable: true
                archived:
                  type: boolean
                  nullable: true
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/EmailDesignSystem"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
    delete:
      summary: Delete Email Design System
      tags:
      - Email Design Systems
      description: Deletes an email design system.
      operationId: deleteEmailDesignSystem
      parameters:
      - name: id
        in: path
        description: Email Design System ID
        required: true
        schema:
          type: integer
      responses:
        '204':
          description: successful
  "/api/v1/email_design_system_parses":
    post:
      summary: Parse Email Design System HTML
      tags:
      - Email Design Systems
      description: Parses an Email Design System HTML into a JSON representation.
      operationId: parseEmailDesignSystemHtml
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                html:
                  type: string
              required:
              - html
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ParsedEmailDesignSystemHtml"
        '422':
          description: validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                        line_number:
                          type: integer
                          nullable: true
                      required:
                      - message
                      - line_number
  "/api/v1/email_design_systems/{emailDesignSystemId}/html":
    get:
      summary: Get Email Design System HTML
      tags:
      - Email Design Systems
      description: Retrieves an Email Design System HTML.
      operationId: getEmailDesignSystemHtml
      parameters:
      - name: emailDesignSystemId
        in: path
        description: Email Design System ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/EmailDesignSystemHtml"
    patch:
      summary: Update Email Design System HTML
      tags:
      - Email Design Systems
      description: Updates an email design system html for the currently logged in
        user.
      operationId: updateEmailDesignSystemHtml
      parameters:
      - name: emailDesignSystemId
        in: path
        description: Email Design System ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                html:
                  type: string
              required:
              - html
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/EmailDesignSystemHtml"
        '422':
          description: validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                        line_number:
                          type: integer
                          nullable: true
                      required:
                      - message
                      - line_number
  "/api/v1/email_design_systems/{emailDesignSystemId}/reorder_components":
    post:
      summary: Reorder Components
      tags:
      - Email Design Systems
      description: Reorders the components.
      operationId: reorderComponents
      parameters:
      - name: emailDesignSystemId
        in: path
        description: Email Design System ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                component_ids:
                  type: array
                  items:
                    type: integer
              required:
              - component_ids
      responses:
        '204':
          description: successful
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/email_design_systems/{emailDesignSystemId}/components":
    get:
      summary: List Components
      tags:
      - Components
      description: Retrieves the components.
      operationId: getComponents
      parameters:
      - name: emailDesignSystemId
        in: path
        description: Email Design System ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ComponentList"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
    post:
      summary: Create Component
      tags:
      - Components
      description: Creates a new component.
      operationId: createComponent
      parameters:
      - name: emailDesignSystemId
        in: path
        description: Email Design System ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                label:
                  type: string
                template:
                  type: string
                field_definitions:
                  type: array
                  items:
                    "$ref": "#/components/schemas/FieldDefinition"
              required:
              - name
              - label
              - template
              - field_definitions
      responses:
        '201':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Component"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/email_design_systems/{emailDesignSystemId}/components/{id}":
    get:
      summary: Get Component
      tags:
      - Components
      description: Retrieves a component.
      operationId: getComponent
      parameters:
      - name: id
        in: path
        description: Component ID
        required: true
        schema:
          type: integer
      - name: emailDesignSystemId
        in: path
        description: Email Design System ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Component"
        '404':
          "$ref": "#/components/responses/NotFound"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
    patch:
      summary: Update Component
      tags:
      - Components
      description: Updates a component.
      operationId: updateComponent
      parameters:
      - name: id
        in: path
        description: Component ID
        required: true
        schema:
          type: integer
      - name: emailDesignSystemId
        in: path
        description: Email Design System ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                label:
                  type: string
                template:
                  type: string
                field_definitions:
                  type: array
                  items:
                    "$ref": "#/components/schemas/FieldDefinition"
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Component"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
    delete:
      summary: Delete Component
      tags:
      - Components
      description: Deletes a component.
      operationId: deleteComponent
      parameters:
      - name: id
        in: path
        description: Component ID
        required: true
        schema:
          type: integer
      - name: emailDesignSystemId
        in: path
        description: Email Design System ID
        required: true
        schema:
          type: integer
      responses:
        '204':
          description: successful
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/dynamic_content_profiles":
    get:
      summary: List Dynamic Content Profiles
      tags:
      - Dynamic Content Profiles
      description: Retrieves the dynamic content profiles for the currently logged
        in user.
      operationId: getDynamicContentProfiles
      parameters:
      - "$ref": "#/components/parameters/per"
      - "$ref": "#/components/parameters/page"
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DynamicContentProfileList"
    post:
      summary: Create Dynamic Content Profile
      tags:
      - Dynamic Content Profiles
      description: Creates a new DynamicContentProfile for the currently logged in
        user.
      operationId: createDynamicContentProfile
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: Mailchimp Profile
              required:
              - name
      responses:
        '201':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DynamicContentProfile"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/dynamic_content_profiles/{id}":
    get:
      summary: Get Dynamic Content Profile
      tags:
      - Dynamic Content Profiles
      description: Retrieves a DynamicContentProfile.
      operationId: getDynamicContentProfile
      parameters:
      - name: id
        in: path
        description: DynamicContentProfile ID
        required: true
        schema:
          type: string
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DynamicContentProfile"
    patch:
      summary: Update Dynamic Content Profile
      tags:
      - Dynamic Content Profiles
      description: Updates a DynamicContentProfile.
      operationId: updateDynamicContentProfile
      parameters:
      - name: id
        in: path
        description: Conditional ID
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: Mailchimp Profile
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DynamicContentProfile"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
    delete:
      summary: Delete Dynamic Content Profile
      tags:
      - Dynamic Content Profiles
      description: Deletes a DynamicContentProfile.
      operationId: deleteDynamicContentProfile
      parameters:
      - name: id
        in: path
        description: DynamicContentProfile ID
        required: true
        schema:
          type: string
      responses:
        '204':
          description: successful
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
  "/api/v1/conditionals":
    get:
      summary: List Conditionals
      tags:
      - Conditionals
      description: Retrieves the conditionals.
      operationId: getConditionals
      parameters:
      - "$ref": "#/components/parameters/per"
      - "$ref": "#/components/parameters/page"
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ConditionalList"
    post:
      summary: Create Conditionals
      tags:
      - Conditionals
      description: Creates a new conditional.
      operationId: createConditional
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                label:
                  type: string
                  example: Over age 30
                default_value:
                  type: string
                  example: TODO
                dynamic_content_profile_values:
                  "$ref": "#/components/schemas/DynamicContentProfileValues"
              required:
              - label
              - default_value
      responses:
        '201':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Conditional"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/conditionals/{id}":
    get:
      summary: Get Conditional
      tags:
      - Conditionals
      description: Retrieves a conditional.
      operationId: getConditional
      parameters:
      - name: id
        in: path
        description: Conditional ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Conditional"
    patch:
      summary: Update Conditional
      tags:
      - Conditionals
      description: Updates a conditional.
      operationId: updateConditional
      parameters:
      - name: id
        in: path
        description: Conditional ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                label:
                  type: string
                  example: Over Age 30s
                default_value:
                  type: string
                  example: TODO
                dynamic_content_profile_values:
                  "$ref": "#/components/schemas/DynamicContentProfileValues"
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Conditional"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
    delete:
      summary: Delete Conditional
      tags:
      - Conditionals
      description: Deletes a conditional.
      operationId: deleteConditional
      parameters:
      - name: id
        in: path
        description: Conditional ID
        required: true
        schema:
          type: integer
      responses:
        '204':
          description: successful
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
  "/api/v1/personalization_tags":
    get:
      summary: List PersonalizationTags
      tags:
      - PersonalizationTags
      description: Retrieves the personalization_tags.
      operationId: getPersonalizationTags
      parameters:
      - "$ref": "#/components/parameters/per"
      - "$ref": "#/components/parameters/page"
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/PersonalizationTagList"
    post:
      summary: Create PersonalizationTag
      tags:
      - PersonalizationTags
      description: Creates a new personalization_tag.
      operationId: createPersonalizationTag
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                label:
                  type: string
                  example: First name
                default_value:
                  type: string
                  example: "{{firstName}}"
                example_value:
                  type: string
                  example: John
                dynamic_content_profile_values:
                  "$ref": "#/components/schemas/DynamicContentProfileValues"
              required:
              - label
              - default_value
              - example_value
      responses:
        '201':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/PersonalizationTag"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/personalization_tags/{id}":
    get:
      summary: Get PersonalizationTag
      tags:
      - PersonalizationTags
      description: Retrieves a personalization_tag.
      operationId: getPersonalizationTag
      parameters:
      - name: id
        in: path
        description: PersonalizationTag ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/PersonalizationTag"
    patch:
      summary: Update PersonalizationTag
      tags:
      - PersonalizationTags
      description: Updates a personalization_tag.
      operationId: updatePersonalizationTag
      parameters:
      - name: id
        in: path
        description: PersonalizationTag ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                label:
                  type: string
                  example: First name
                default_value:
                  type: string
                  example: "{{firstName}}"
                example_value:
                  type: string
                  example: John
                dynamic_content_profile_values:
                  "$ref": "#/components/schemas/DynamicContentProfileValues"
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/PersonalizationTag"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
    delete:
      summary: Delete PersonalizationTag
      tags:
      - PersonalizationTags
      description: Deletes a personalization_tag.
      operationId: deletePersonalizationTag
      parameters:
      - name: id
        in: path
        description: PersonalizationTag ID
        required: true
        schema:
          type: integer
      responses:
        '204':
          description: successful
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
  "/api/v1/images":
    get:
      summary: List Images
      tags:
      - Images
      description: Retrieves the images.
      operationId: getImages
      parameters:
      - "$ref": "#/components/parameters/per"
      - "$ref": "#/components/parameters/page"
      - name: search
        in: query
        description: Filter images by search term
        required: false
        schema:
          type: string
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ImageList"
    post:
      summary: Create Image
      tags:
      - Images
      description: Creates a new image.
      operationId: createImage
      parameters: []
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
              required:
              - file
      responses:
        '201':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Image"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/images/{id}":
    patch:
      summary: Update Image
      tags:
      - Images
      description: Updates an image.
      operationId: updateImage
      parameters:
      - name: id
        in: path
        description: Image ID
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: New Name
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Image"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
    delete:
      summary: Delete Image
      tags:
      - Images
      description: Deletes an image.
      operationId: deleteImage
      parameters:
      - name: id
        in: path
        description: Image ID
        required: true
        schema:
          type: string
      responses:
        '204':
          description: successful
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/users":
    get:
      summary: List users
      tags:
      - Users
      description: Retrieves the users.
      operationId: getUsers
      parameters:
      - "$ref": "#/components/parameters/per"
      - "$ref": "#/components/parameters/page"
      - name: search
        in: query
        description: Filter users by search term
        required: false
        schema:
          type: string
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/UserList"
    post:
      summary: Create user
      tags:
      - Users
      description: Creates a new user.
      operationId: createUser
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                first_name:
                  type: string
                last_name:
                  type: string
                email:
                  type: string
                role:
                  type: string
                  enum:
                  - admin
                  - developer
                  - editor
                  - viewer
              required:
              - first_name
              - last_name
              - email
              - role
      responses:
        '201':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/User"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/users/{id}":
    get:
      summary: Get user
      tags:
      - Users
      description: Retrieves a user.
      operationId: getUser
      parameters:
      - name: id
        in: path
        description: User ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/User"
    patch:
      summary: Update user
      tags:
      - Users
      description: Updates a user.
      operationId: updateUser
      parameters:
      - name: id
        in: path
        description: User ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                role:
                  type: string
                  enum:
                  - admin
                  - developer
                  - editor
                  - viewer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/User"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
    delete:
      summary: Delete user
      tags:
      - Users
      description: Deletes a user.
      operationId: deleteUser
      parameters:
      - name: id
        in: path
        description: User ID
        required: true
        schema:
          type: integer
      responses:
        '204':
          description: successful
        '400':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
  "/api/v1/connectors":
    get:
      summary: List connectors
      tags:
      - Connectors
      description: Retrieves connectors.
      operationId: getConnectors
      parameters:
      - "$ref": "#/components/parameters/per"
      - "$ref": "#/components/parameters/page"
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ConnectorList"
    post:
      summary: Creates a connector.
      tags:
      - Connectors
      description: Creates a new connector.
      operationId: createConnector
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Connector name
                  example: Mailchimp
                integration_name:
                  type: string
                  description: Integration name
                  example: mailchimp
                settings:
                  type: object
                  additionalProperties: true
              required:
              - name
              - integration_name
              - settings
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Connector"
        '422':
          "$ref": "#/components/responses/ValidationError"
  "/api/v1/connectors/{id}":
    get:
      summary: Get connector
      tags:
      - Connectors
      description: Retrieves a single connector by ID.
      operationId: getConnector
      parameters:
      - name: id
        in: path
        description: Connector ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Connector"
    patch:
      summary: Update connector
      tags:
      - Connectors
      description: Updates a connector.
      operationId: updateConnector
      parameters:
      - name: id
        in: path
        description: Project ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Connector name
                  example: Mailchimp
                integration_name:
                  type: string
                  description: Integration name
                  example: mailchimp
                settings:
                  type: object
                  additionalProperties: true
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Connector"
        '422':
          "$ref": "#/components/responses/ValidationError"
    delete:
      summary: Delete connector
      tags:
      - Connectors
      description: Deletes a connector.
      operationId: deleteConnector
      parameters:
      - name: id
        in: path
        description: Connector ID
        required: true
        schema:
          type: integer
      responses:
        '204':
          description: successful
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
  "/api/v1/tools/html_email_to_text_converter":
    post:
      summary: Convert HTML Email to Text
      tags:
      - Tools
      description: Converts HTML Email to Text
      operationId: convertHtmlToText
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                html:
                  type: string
              required:
              - html
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                type: object
                properties:
                  text:
                    type: string
                required:
                - text
        '422':
          "$ref": "#/components/responses/ValidationError"
  "/api/v1/external_connector_resources":
    get:
      summary: List external connector resources
      tags:
      - ExternalConnectorResources
      description: Retrieves the external connector resources
      operationId: getExternalConnectorResources
      parameters:
      - name: email_id
        in: query
        description: Email ID
        required: false
        schema:
          type: integer
      - name: connector_id
        in: query
        description: Connector ID
        required: false
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ExternalConnectorResourceList"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/ai_agents":
    get:
      summary: List AI agents
      tags:
      - AIAgents
      description: Retrieves the AI agents
      operationId: getAiAgents
      parameters:
      - "$ref": "#/components/parameters/per"
      - "$ref": "#/components/parameters/page"
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/AiAgentList"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
    post:
      summary: Create AI agent
      tags:
      - AIAgents
      description: Creates a new AI agent.
      operationId: createAiAgent
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                company_name:
                  type: string
                company_overview:
                  type: string
                tone:
                  type: string
                guidelines:
                  type: string
              required:
              - name
      responses:
        '201':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/AiAgent"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/ai_agents/{id}":
    get:
      summary: Get AI agent
      tags:
      - AIAgents
      description: Retrieves a single AI agent by ID.
      operationId: getAiAgent
      parameters:
      - name: id
        in: path
        description: AI agent ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/AiAgent"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
    patch:
      summary: Update AI agent
      tags:
      - AIAgents
      description: Updates a single AI agent by ID.
      operationId: updateAiAgent
      parameters:
      - name: id
        in: path
        description: AI agent ID
        required: true
        schema:
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                company_name:
                  type: string
                company_overview:
                  type: string
                tone:
                  type: string
                guidelines:
                  type: string
      responses:
        '200':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/AiAgent"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
    delete:
      summary: Delete AI agent
      tags:
      - AIAgents
      description: Deletes a single AI agent by ID.
      operationId: deleteAiAgent
      parameters:
      - name: id
        in: path
        description: AI agent ID
        required: true
        schema:
          type: integer
      responses:
        '204':
          description: successful
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
  "/api/v1/renders":
    post:
      summary: Render
      tags:
      - Renders
      description: Renders the selected components of an email design system
      operationId: createRender
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/CreateRender"
      responses:
        '201':
          description: successful
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/RenderOutput"
        '422':
          "$ref": "#/components/responses/ValidationError"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
servers:
- url: "{{app_url}"
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Bearer token authentication
    CookieAuth:
      type: apiKey
      in: cookie
      name: _emailshepherd_session
  parameters:
    per:
      name: per
      in: query
      description: Number of records per page
      required: false
      schema:
        type: integer
        default: 10
    page:
      name: page
      in: query
      description: Page number
      required: false
      schema:
        type: integer
        default: 1
  schemas:
    OrganizationSubscriptionDetails:
      type: object
      properties:
        status:
          type: string
          example: active
          nullable: true
          enum:
          - incomplete
          - incomplete_expired
          - trialing
          - active
          - past_due
          - canceled
          - unpaid
          - paused
        ends_at:
          type: string
          format: date-time
          example: '2024-01-01T00:00:00.000Z'
          nullable: true
        free_trial_ends_at:
          type: string
          format: date-time
          example: '2024-01-01T00:00:00.000Z'
          nullable: true
        current_period_start:
          type: string
          format: date-time
          example: '2024-01-01T00:00:00.000Z'
          nullable: true
        current_period_end:
          type: string
          format: date-time
          example: '2024-01-01T00:00:00.000Z'
          nullable: true
        has_subscription:
          type: boolean
          example: true
          nullable: true
        is_on_free_trial:
          type: boolean
          example: true
        free_trial_has_expired:
          type: boolean
          example: true
        is_active:
          type: boolean
          example: true
        is_canceled:
          type: boolean
          example: true
        is_on_grace_period:
          type: boolean
          example: true
        is_past_due:
          type: boolean
          example: true
        is_unpaid:
          type: boolean
          example: true
        is_incomplete:
          type: boolean
          example: true
        is_ended:
          type: boolean
          example: true
        product_name:
          type: string
          example: Pro Plan
          nullable: true
        product_key:
          type: string
          example: pro_plan
          nullable: true
        interval:
          type: string
          enum:
          - month
          - year
          nullable: true
        beta_signup:
          type: boolean
          example: true
      required:
      - status
      - has_subscription
      - is_on_free_trial
      - free_trial_has_expired
      - is_active
      - is_canceled
      - is_on_grace_period
      - is_past_due
      - is_unpaid
      - is_incomplete
      - is_ended
      - product_name
      - product_key
      - interval
      - beta_signup
    OrganizationFeatures:
      type: object
      properties:
        ai_email_design_system_generation:
          type: boolean
          example: true
        ai_email_generation:
          type: boolean
          example: true
    Organization:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        name:
          type: string
          example: My Organization
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        free_trial_ends_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        email:
          type: string
          example: joe@example.com
        country:
          type: string
          example: US
        subscription_details:
          "$ref": "#/components/schemas/OrganizationSubscriptionDetails"
        features:
          "$ref": "#/components/schemas/OrganizationFeatures"
      required:
      - id
      - name
      - free_trial_ends_at
      - created_at
      - updated_at
      - email
      - country
      - subscription_details
      - features
    ValidationError:
      type: object
      required:
      - errors
      - message
      properties:
        message:
          type: string
          example: Failed to save
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
      example:
        errors:
          username:
          - Username is required.
          - Username must be unique.
          email:
          - Invalid email format.
    Error:
      type: object
      required:
      - message
      properties:
        message:
          type: string
          example: Record not found
    Project:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        name:
          type: string
          example: Black Friday 2023
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        description:
          type: string
          example: Black Friday 2023 Marketing Campaign
        organization_id:
          type: integer
          example: 12345
      required:
      - id
      - name
      - created_at
      - organization_id
    Pagination:
      type: object
      properties:
        per:
          type: integer
          example: 10
        page:
          type: integer
          example: 1
        total:
          type: integer
          example: 100
      required:
      - per
      - page
      - total
    ProjectList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/Project"
        pagination:
          "$ref": "#/components/schemas/Pagination"
      required:
      - results
      - pagination
    User:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        first_name:
          type: string
          example: Joe
        last_name:
          type: string
          example: Cottam
        email:
          type: string
          format: email
          example: joe@example.com
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        requires_email_confirmation:
          type: boolean
          example: false
        organization_id:
          type: integer
          example: 12345
        role:
          type: string
          enum:
          - admin
          - developer
          - editor
          - viewer
        invitation_sent_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
          nullable: true
        invitation_accepted_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
          nullable: true
        permissions:
          type: array
          items:
            type: string
            enum:
            - update_emails
            - create_emails
            - delete_emails
            - update_library_images
            - create_library_images
            - delete_library_images
            - access_all_projects
            - update_projects
            - create_projects
            - delete_projects
            - update_email_design_systems
            - create_email_design_systems
            - delete_email_design_systems
            - update_dynamic_content_profiles
            - create_dynamic_content_profiles
            - delete_dynamic_content_profiles
            - update_personalization_tags
            - create_personalization_tags
            - delete_personalization_tags
            - update_conditionals
            - create_conditionals
            - delete_conditionals
            - create_connectors
            - update_connectors
            - delete_connectors
            - create_exports
            - update_organization
            - manage_billing
            - manage_api_keys
            - view_audit_logs
            - send_test_emails
            - update_users
            - create_users
            - delete_users
            - update_ai_agents
            - create_ai_agents
            - delete_ai_agents
        profile_image_url:
          type: string
          format: url
          example: https://example.com/profile.jpg
          nullable: true
        wants_marketing_emails:
          type: boolean
          example: false
      required:
      - id
      - email
      - first_name
      - last_name
      - created_at
      - updated_at
      - organization_id
      - requires_email_confirmation
      - role
      - invitation_sent_at
      - invitation_accepted_at
      - permissions
      - profile_image_url
      - wants_marketing_emails
    UserList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/User"
        pagination:
          "$ref": "#/components/schemas/Pagination"
      required:
      - results
      - pagination
    EmailContentSubject:
      type: object
      properties:
        conditional_id:
          type: integer
        branch_content:
          type: object
          additionalProperties:
            type: object
            additionalProperties:
              type: string
              example: My Email Subject in a Specific Locale
            description: Localized email subject, keyed by BCP47 locale
      required:
      - branch_content
    EmailContentPreheader:
      type: object
      properties:
        conditional_id:
          type: integer
        branch_content:
          type: object
          additionalProperties:
            type: object
            additionalProperties:
              type: string
              example: My Email Preheader in a Specific Locale
            description: Localized email preheader, keyed by BCP47 locale
      required:
      - branch_content
    FieldValue:
      type: object
      properties:
        value:
          oneOf:
          - type: string
          - type: number
          - type: boolean
      required:
      - value
    LiquidVariablesMap:
      type: object
      additionalProperties:
        "$ref": "#/components/schemas/FieldValue"
    LocalesMap:
      type: object
      additionalProperties:
        "$ref": "#/components/schemas/LiquidVariablesMap"
    BranchKeysMap:
      type: object
      additionalProperties:
        "$ref": "#/components/schemas/LocalesMap"
    ComponentInstance:
      type: object
      properties:
        id:
          type: string
          example: bd1c1b82-1a7b-4f0f-b079-30c1d4189bed
        name:
          type: string
          example: My Component
        component_id:
          type: integer
        conditional_id:
          type: integer
        field_values:
          "$ref": "#/components/schemas/BranchKeysMap"
      required:
      - component_id
      - id
    EmailContent:
      type: object
      properties:
        subject:
          "$ref": "#/components/schemas/EmailContentSubject"
        preheader:
          "$ref": "#/components/schemas/EmailContentPreheader"
        container_component_instance:
          "$ref": "#/components/schemas/ComponentInstance"
        component_instances:
          type: array
          items:
            "$ref": "#/components/schemas/ComponentInstance"
      required:
      - subject
      - preheader
      - container_component_instance
      - component_instances
    Locale:
      type: string
      example: en-US
      enum:
      - ar-SA
      - bn-BD
      - bn-IN
      - cs-CZ
      - da-DK
      - de-AT
      - de-CH
      - de-DE
      - el-GR
      - en-AU
      - en-CA
      - en-GB
      - en-IE
      - en-IN
      - en-NZ
      - en-US
      - en-ZA
      - es-AR
      - es-CL
      - es-CO
      - es-ES
      - es-MX
      - es-US
      - fi-FI
      - fr-BE
      - fr-CA
      - fr-CH
      - fr-FR
      - he-IL
      - hi-IN
      - hu-HU
      - id-ID
      - it-CH
      - it-IT
      - ja-JP
      - ko-KR
      - nl-BE
      - nl-NL
      - no-NO
      - pl-PL
      - pt-BR
      - pt-PT
      - ro-RO
      - ru-RU
      - sk-SK
      - sv-SE
      - ta-IN
      - ta-LK
      - th-TH
      - tr-TR
      - zh-CN
      - zh-HK
    Email:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        name:
          type: string
          example: My Email
        project_id:
          type: integer
          example: 12345
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        organization_id:
          type: integer
          example: 12345
        email_design_system_id:
          type: integer
          example: 12345
        email_content:
          "$ref": "#/components/schemas/EmailContent"
        default_locale:
          "$ref": "#/components/schemas/Locale"
        locales:
          type: array
          items:
            "$ref": "#/components/schemas/Locale"
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        last_updated_by:
          type: object
          properties:
            id:
              type: integer
              example: 12345
            first_name:
              type: string
              example: John
            last_name:
              type: string
              example: Smith
            profile_image_url:
              type: string
              example: https://example.com/profile.jpg
              nullable: true
          required:
          - id
          - first_name
          - last_name
          - profile_image_url
          nullable: true
        create_with_ai:
          type: boolean
          example: false
          nullable: true
        prompt:
          type: string
          example: Write a welcome email to a new customer
          nullable: true
        ai_generation_status:
          type: string
          enum:
          - generating
          - done
          example: generating
          nullable: true
        ai_agent_id:
          type: integer
          example: 12345
          nullable: true
      required:
      - id
      - name
      - created_at
      - updated_at
      - organization_id
      - project_id
      - email_design_system_id
      - email_content
      - default_locale
      - locales
      - last_updated_by
      - create_with_ai
      - prompt
      - ai_generation_status
      - ai_agent_id
    EmailList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/Email"
        pagination:
          "$ref": "#/components/schemas/Pagination"
      required:
      - results
      - pagination
    EmailTranslation:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        email_id:
          type: integer
          example: 12345
        organization_id:
          type: integer
          example: 12345
        target_locales:
          type: array
          items:
            type: string
        status:
          type: string
          enum:
          - in_progress
          - completed
          - failed
        locale_statuses:
          type: object
          additionalProperties:
            type: string
            enum:
            - in_progress
            - completed
            - failed
      required:
      - id
      - email_id
      - target_locales
      - status
      - locale_statuses
    ExportOptions:
      type: object
      properties:
        locales:
          type: array
          items:
            "$ref": "#/components/schemas/Locale"
        export_field_values:
          type: object
          additionalProperties:
            type: string
        per_locale_options:
          type: object
          additionalProperties:
            type: object
            properties:
              resource_name:
                type: string
              update_previous_export:
                type: boolean
          required:
          - resource_name
      required:
      - locales
    ExportMetadata:
      type: object
      properties:
        conditional_ids:
          type: array
          items:
            type: integer
            example: 12345
        personalization_tag_ids:
          type: array
          items:
            type: integer
            example: 12345
        image_ids:
          type: array
          items:
            type: integer
            example: 12345
    ExportErrors:
      type: object
      properties:
        base:
          type: array
          nullable: true
          items:
            type: string
            example: My Error
        additionalProperties:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
              example: My Error
    Export:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        organization_id:
          type: integer
          example: 12345
        connector_id:
          type: integer
          example: 12345
          nullable: true
        email_id:
          type: integer
          example: 12345
        dynamic_content_profile_id:
          type: string
          example: a8c5c5c0-5b1a-4b5a-9b0a-5e8b5c5c5c5c
          nullable: true
        status:
          type: string
          enum:
          - in_progress
          - completed
          - failed
          example: in_progress
        export_type:
          type: string
          enum:
          - json
          - html
          - connector
          example: html
        options:
          "$ref": "#/components/schemas/ExportOptions"
        integration_name:
          type: string
          example: Brevo
          nullable: true
        metadata:
          "$ref": "#/components/schemas/ExportMetadata"
        export_errors:
          "$ref": "#/components/schemas/ExportErrors"
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        download_zip_url:
          type: string
          example: https://www.example.com/download.zip
        download_json_url:
          type: string
          example: https://www.example.com/download.json
          nullable: true
        open_in_integration_url:
          type: string
          example: https://www.example.com/integrations/mailchimp/export/12345
          nullable: true
      required:
      - id
      - connector_id
      - organization_id
      - dynamic_content_profile_id
      - email_id
      - status
      - options
      - integration_name
      - metadata
      - export_type
      - export_errors
      - created_at
      - updated_at
      - download_json_url
      - open_in_integration_url
    ExportList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/Export"
        pagination:
          "$ref": "#/components/schemas/Pagination"
      required:
      - results
      - pagination
    EmailDesignSystem:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        name:
          type: string
          example: My Email Design System
        description:
          type: string
          example: My Email Design System
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        organization_id:
          type: integer
          example: 12345
        screenshot_url:
          type: string
          example: https://www.example.com/screenshot.png
        upload_status:
          type: string
          example: success
          enum:
          - ready
          - processing
        create_with_ai:
          type: boolean
          example: false
        prompt:
          type: string
          example: I want an email design system with a header, a footer, and a content
            section.
          nullable: true
        ai_generation_status:
          type: string
          example: generating
          enum:
          - generating
          - done
          nullable: true
        archived:
          type: boolean
          example: false
      required:
      - id
      - name
      - created_at
      - organization_id
      - screenshot_url
      - upload_status
      - create_with_ai
      - prompt
      - ai_generation_status
      - archived
    EmailDesignSystemList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/EmailDesignSystem"
        pagination:
          "$ref": "#/components/schemas/Pagination"
      required:
      - results
      - pagination
    TextFieldDefinition:
      type: object
      properties:
        type:
          type: string
          enum:
          - text
        label:
          type: string
        liquid_variable:
          type: string
        visible_if:
          type: string
        default_value:
          type: string
        minLength:
          type: integer
          format: int32
          nullable: true
        maxLength:
          type: integer
          format: int32
          nullable: true
        hint:
          type: string
      required:
      - type
      - label
      - liquid_variable
      - default_value
    NumberFieldDefinition:
      type: object
      properties:
        type:
          type: string
          enum:
          - number
        label:
          type: string
        liquid_variable:
          type: string
        visible_if:
          type: string
        default_value:
          type: number
        min:
          type: number
          nullable: true
        max:
          type: number
          nullable: true
        hint:
          type: string
      required:
      - type
      - label
      - liquid_variable
      - default_value
    EnumFieldDefinition:
      type: object
      properties:
        type:
          type: string
          enum:
          - enum
        label:
          type: string
        liquid_variable:
          type: string
        visible_if:
          type: string
        default_value:
          type: string
        options:
          type: array
          items:
            type: object
            properties:
              label:
                type: string
              value:
                type: string
            required:
            - label
            - value
        hint:
          type: string
      required:
      - type
      - label
      - liquid_variable
      - default_value
      - options
    BooleanFieldDefinition:
      type: object
      properties:
        type:
          type: string
          enum:
          - boolean
        label:
          type: string
        liquid_variable:
          type: string
        visible_if:
          type: string
        default_value:
          type: boolean
        hint:
          type: string
      required:
      - type
      - label
      - liquid_variable
      - default_value
    UrlFieldDefinition:
      type: object
      properties:
        type:
          type: string
          enum:
          - url
        label:
          type: string
        liquid_variable:
          type: string
        visible_if:
          type: string
        default_value:
          type: string
        hint:
          type: string
      required:
      - type
      - label
      - liquid_variable
      - default_value
    ImageFieldDefinition:
      type: object
      properties:
        type:
          type: string
          enum:
          - image
        label:
          type: string
        liquid_variable:
          type: string
        visible_if:
          type: string
        default_value:
          type: string
        hint:
          type: string
      required:
      - type
      - label
      - liquid_variable
      - default_value
    ColorFieldDefinition:
      type: object
      properties:
        type:
          type: string
          enum:
          - color
        label:
          type: string
        liquid_variable:
          type: string
        visible_if:
          type: string
        default_value:
          type: string
        hint:
          type: string
      required:
      - type
      - label
      - liquid_variable
      - default_value
    RichTextFieldDefinition:
      type: object
      properties:
        type:
          type: string
          enum:
          - rich_text
        label:
          type: string
        liquid_variable:
          type: string
        visible_if:
          type: string
        default_value:
          type: string
        hint:
          type: string
      required:
      - type
      - label
      - liquid_variable
      - default_value
    FieldDefinition:
      oneOf:
      - "$ref": "#/components/schemas/TextFieldDefinition"
      - "$ref": "#/components/schemas/NumberFieldDefinition"
      - "$ref": "#/components/schemas/EnumFieldDefinition"
      - "$ref": "#/components/schemas/BooleanFieldDefinition"
      - "$ref": "#/components/schemas/UrlFieldDefinition"
      - "$ref": "#/components/schemas/ImageFieldDefinition"
      - "$ref": "#/components/schemas/ColorFieldDefinition"
      - "$ref": "#/components/schemas/RichTextFieldDefinition"
    Component:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        name:
          type: string
          example: MyComponent
        label:
          type: string
          example: My Component
        email_design_system_id:
          type: integer
          example: 12345
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        container:
          type: boolean
          example: false
          nullable: true
        template:
          type: string
          example: "<div>My Component</div>"
        field_definitions:
          type: array
          items:
            "$ref": "#/components/schemas/FieldDefinition"
        screenshot_url:
          type: string
          example: https://www.example.com/screenshot.png
        position:
          type: integer
          example: 1
          nullable: true
      required:
      - id
      - name
      - created_at
      - updated_at
      - email_design_system_id
      - field_definitions
      - template
      - screenshot_url
      - label
      - position
    ParsedEmailDesignSystemHtml:
      type: object
      properties:
        container_component:
          "$ref": "#/components/schemas/Component"
        components:
          type: array
          items:
            "$ref": "#/components/schemas/Component"
      required:
      - container_component
      - components
    EmailDesignSystemHtml:
      type: object
      properties:
        html:
          type: string
          example: "<html><head></head><body><p>Hello, World!</p></body></html>"
      required:
      - html
    ComponentList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/Component"
      required:
      - results
    DynamicContentProfile:
      type: object
      properties:
        id:
          type: string
          example: uuid TODO
        name:
          type: string
          example: Mailchimp Profile
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        organization_id:
          type: integer
          example: 12345
      required:
      - id
      - name
      - created_at
      - updated_at
      - organization_id
    DynamicContentProfileList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/DynamicContentProfile"
        pagination:
          "$ref": "#/components/schemas/Pagination"
      required:
      - results
      - pagination
    Syntax:
      type: object
      properties:
        closing:
          type: string
        branch_values:
          type: object
          description: Key-value pairs where the key is the branch key and the value
            is the branch syntax
          additionalProperties:
            type: string
      required:
      - closing
      - branch_values
    Branch:
      type: object
      properties:
        key:
          type: string
          example: key
        label:
          type: string
          example: label
      required:
      - key
      - label
    DynamicContentProfileSyntaxes:
      type: object
      additionalProperties:
        "$ref": "#/components/schemas/Syntax"
    Conditional:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        label:
          type: string
          example: Over age 30s
        default_syntax:
          "$ref": "#/components/schemas/Syntax"
        branches:
          type: array
          items:
            "$ref": "#/components/schemas/Branch"
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        organization_id:
          type: integer
          example: 12345
        dynamic_content_profile_syntaxes:
          "$ref": "#/components/schemas/DynamicContentProfileSyntaxes"
      required:
      - id
      - label
      - default_syntax
      - branches
      - created_at
      - updated_at
      - organization_id
      - dynamic_content_profile_syntaxes
    ConditionalList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/Conditional"
        pagination:
          "$ref": "#/components/schemas/Pagination"
      required:
      - results
      - pagination
    DynamicContentProfileValues:
      type: object
      additionalProperties:
        type: string
    PersonalizationTag:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        label:
          type: string
          example: First name
        default_value:
          type: string
          example: "{{firstName}}"
        example_value:
          type: string
          example: John
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        organization_id:
          type: integer
          example: 12345
        dynamic_content_profile_values:
          "$ref": "#/components/schemas/DynamicContentProfileValues"
      required:
      - id
      - label
      - default_value
      - example_value
      - created_at
      - updated_at
      - organization_id
      - dynamic_content_profile_values
    PersonalizationTagList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/PersonalizationTag"
        pagination:
          "$ref": "#/components/schemas/Pagination"
      required:
      - results
      - pagination
    Image:
      type: object
      properties:
        id:
          type: string
          example: bd1c1b82-1a7b-4f0f-b079-30c1d4189bed
        name:
          type: string
          example: My Image
        filename:
          type: string
          example: image.png
        width:
          type: integer
          example: 100
        height:
          type: integer
          example: 100
        file_size:
          type: integer
          example: 1000
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        organization_id:
          type: integer
          example: 12345
        public_url:
          type: string
          example: https://www.example.com/image.png
      required:
      - id
      - name
      - filename
      - created_at
      - updated_at
      - organization_id
      - public_url
      - height
      - width
      - file_size
    ImageList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/Image"
        pagination:
          "$ref": "#/components/schemas/Pagination"
      required:
      - results
      - pagination
    Connector:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        name:
          type: string
          example: Mailchimp
        integration_name:
          type: string
          example: mailchimp
        settings:
          type: object
          additionalProperties: true
          properties:
            setup_fields:
              type: object
              additionalProperties: true
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        oauth_authorization_url:
          type: string
          example: https://app.constantcontact.com/oauth2/v1/authorize?client_id=12345&redirect_uri=https://app.constantcontact.com/oauth2/v1/callback&response_type=code&scope=email_profile_read
          nullable: true
      required:
      - id
      - name
      - integration_name
      - oauth_authorization_url
      - settings
      - created_at
      - updated_at
    ConnectorList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/Connector"
        pagination:
          "$ref": "#/components/schemas/Pagination"
      required:
      - results
      - pagination
    ExternalConnectorResource:
      type: object
      properties:
        external_id:
          type: string
        external_name:
          type: string
        export_id:
          type: integer
        connector_id:
          type: integer
        last_exported_at:
          type: string
          format: date-time
        email_id:
          type: integer
        locale:
          "$ref": "#/components/schemas/Locale"
        external_metadata:
          type: object
          additionalProperties: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
      - external_id
      - external_name
      - export_id
      - connector_id
      - last_exported_at
      - email_id
      - locale
      - created_at
      - updated_at
    ExternalConnectorResourceList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/ExternalConnectorResource"
      required:
      - results
    AiAgent:
      type: object
      properties:
        id:
          type: integer
          example: 12345
        name:
          type: string
          example: My AI Agent
        company_name:
          type: string
          example: My Company
          nullable: true
        company_overview:
          type: string
          example: My Company is a company that makes widgets.
          nullable: true
        tone:
          type: string
          example: My Company is a company that makes widgets.
          nullable: true
        guidelines:
          type: string
          example: My Company is a company that makes widgets.
          nullable: true
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
      required:
      - id
      - name
      - company_name
      - company_overview
      - tone
      - guidelines
      - created_at
      - updated_at
    AiAgentList:
      type: object
      properties:
        results:
          type: array
          items:
            "$ref": "#/components/schemas/AiAgent"
        pagination:
          "$ref": "#/components/schemas/Pagination"
      required:
      - results
      - pagination
    RenderComponentInstance:
      type: object
      properties:
        component_id:
          type: integer
        field_values:
          type: object
          additionalProperties:
            oneOf:
            - type: string
            - type: boolean
            - type: number
      required:
      - component_id
    CreateRender:
      type: object
      properties:
        email_design_system_id:
          type: integer
          description: ID of the email design system
        content:
          type: object
          properties:
            subject:
              type: string
              description: Subject of the email
            preheader:
              type: string
              description: Preheader of the email
            container_component_instance:
              "$ref": "#/components/schemas/RenderComponentInstance"
            component_instances:
              type: array
              items:
                "$ref": "#/components/schemas/RenderComponentInstance"
          required:
          - subject
          - preheader
          - container_component_instance
          - component_instances
      required:
      - email_design_system_id
      - content
    RenderOutput:
      type: object
      properties:
        html:
          type: string
          description: HTML output of the rendered components
        created_at:
          type: string
          format: date-time
          example: '2023-08-23T10:30:00.000Z'
  responses:
    ValidationError:
      description: Unprocessable Entity
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ValidationError"
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/Error"
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/Error"
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/Error"
security:
- CookieAuth: []
- BearerAuth: []
