openapi: 3.0.2
info:
  title: Template Service
  description: Template Service API
  version: 2.0.0
servers:
  - url: https://tenant.p.newstore.net/v0/d
    description: Production environment
  - url: https://tenant.s.newstore.net/v0/d
    description: Staging environment
  - url: http://templates.web-platform.c.p.newstore.net
    description: Platform internal
paths:
  /templates/styles:
    get:
      summary: List Styles
      description: Get all styles
      operationId: list_styles
      parameters:
        - required: true
          schema:
            title: Tenant
            type: string
          name: tenant
          in: header
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/StyleSheet'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /templates/styles/{style_name}:
    get:
      summary: Get Style
      description: Get style
      operationId: get_style
      parameters:
        - required: true
          schema:
            title: Style Name
            type: string
          name: style_name
          in: path
        - required: true
          schema:
            title: Tenant
            type: string
          name: tenant
          in: header
      responses:
        '200':
          description: Successful Response
          content:
            text/plain:
              schema:
                type: string
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    put:
      summary: Put Style
      description: Update style
      operationId: update_style
      parameters:
        - required: true
          schema:
            title: Style Name
            type: string
          name: style_name
          in: path
        - required: true
          schema:
            $ref: '#/components/schemas/ContentTypeHeader'
          name: content-type
          in: header
        - required: true
          schema:
            title: Tenant
            type: string
          name: tenant
          in: header
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PutStylePayload'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            text/plain:
              schema:
                type: string
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /templates/templates:
    get:
      summary: List Templates
      description: Get all templates
      operationId: list_templates
      parameters:
        - required: true
          schema:
            title: Tenant
            type: string
          name: tenant
          in: header
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Template'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /templates/templates/{template_id}/sample_data:
    get:
      summary: Get Template Sample Data
      description: Get template sample data
      operationId: get_template_sample_data
      parameters:
        - required: true
          schema:
            title: Template Id
            type: string
          name: template_id
          in: path
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /templates/templates/{template_id}/localization/{locale}/sample_data:
    put:
      summary: Put Sample Data
      description: Update sample data by locale
      operationId: update_sample_data_by_locale
      parameters:
        - required: true
          schema:
            title: Template ID
            type: string
          name: template_id
          in: path
        - required: true
          schema:
            title: Locale
            type: string
          name: locale
          in: path
        - required: true
          schema:
            title: Tenant
            type: string
          name: Tenant
          in: header
      requestBody:
        description: The sample data as plain text.
        required: true
        content:
          text/plain:
            schema:
              type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    get:
      summary: Get Sample Data
      description: Get sample data by locale
      operationId: get_sample_data_by_locale
      parameters:
        - required: true
          schema:
            title: Template Id
            type: string
          name: template_id
          in: path
        - required: true
          schema:
            title: Locale
            type: string
          name: locale
          in: path
        - required: true
          schema:
            title: Tenant
            type: string
          name: Tenant
          in: header
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
  /templates/templates/{template_id}/documentation:
    get:
      summary: Get Template Documentation
      description: Get template documentation
      operationId: >-
        get_template_documentation_templates_templates__template_id__documentation_get
      parameters:
        - required: true
          schema:
            title: Template Id
            type: string
          name: template_id
          in: path
        - required: true
          schema:
            title: Tenant
            type: string
          name: tenant
          in: header
      responses:
        '200':
          description: Successful Response
          content:
            text/html:
              schema:
                type: string
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /templates/templates/{template_id}/render:
    post:
      summary: Render Template
      description: Render template
      operationId: render_template
      parameters:
        - required: true
          schema:
            title: Template Id
            type: string
          name: template_id
          in: path
        - required: true
          schema:
            $ref: '#/components/schemas/ContentTypeHeader'
          name: content-type
          in: header
        - required: true
          schema:
            title: Tenant
            type: string
          name: tenant
          in: header
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RenderPayload'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RenderResponse'
        '307':
          description: >-
            Request redirect to a different region. In case of rendering
            templates with PII content, the application automatically redirect
            to EU region. (Please follow the redirect).
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /templates/templates/{template_id}/preview:
    post:
      summary: Preview Template
      description: Preview template
      operationId: preview_template
      parameters:
        - required: true
          schema:
            title: Template Id
            type: string
          name: template_id
          in: path
        - required: true
          schema:
            $ref: '#/components/schemas/ContentTypeHeader'
          name: content-type
          in: header
        - required: true
          schema:
            title: Tenant
            type: string
          name: tenant
          in: header
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PreviewPayload'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            text/plain:
              schema:
                type: string
            text/html:
              schema:
                type: string
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /templates/templates/{template_id}/localization/{locale}:
    get:
      summary: Get Template
      description: Get template by locale
      operationId: get_template_by_locale
      parameters:
        - required: true
          schema:
            title: Template Id
            type: string
          name: template_id
          in: path
        - required: true
          schema:
            title: Locale
            type: string
          name: locale
          in: path
        - required: true
          schema:
            title: Tenant
            type: string
          name: tenant
          in: header
      responses:
        '200':
          description: Successful Response
          content:
            text/plain:
              schema:
                type: string
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    put:
      summary: Put Template
      description: Update template by locale
      operationId: update_template_by_locale
      parameters:
        - required: true
          schema:
            title: Template Id
            type: string
          name: template_id
          in: path
        - required: true
          schema:
            title: Locale
            type: string
          name: locale
          in: path
        - required: true
          schema:
            $ref: '#/components/schemas/ContentTypeHeader'
          name: content-type
          in: header
        - required: true
          schema:
            title: Tenant
            type: string
          name: tenant
          in: header
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    delete:
      summary: Delete Template
      description: Delete template by locale
      operationId: delete_template_by_locale
      parameters:
        - required: true
          schema:
            title: Template Id
            type: string
          name: template_id
          in: path
        - required: true
          schema:
            title: Locale
            type: string
          name: locale
          in: path
        - required: true
          schema:
            $ref: '#/components/schemas/ContentTypeHeader'
          name: content-type
          in: header
        - required: true
          schema:
            title: Tenant
            type: string
          name: tenant
          in: header
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ContentTypeHeader:
      title: ContentTypeHeader
      enum:
        - application/json
      description: An enumeration.
    ContentTypes:
      title: ContentTypes
      enum:
        - html
        - pdf
        - text
      description: The supported content types
    HTTPValidationError:
      title: HTTPValidationError
      type: object
      properties:
        detail:
          title: Detail
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
    Locale:
      title: Locale
      type: string
      description: >-
        Locale to use for rendering. If not specified, the default locale
        (en_US) will be used. A locale is defined by a language and country
        separated by an underscore. Example locales are en_US, en_UK, de_DE,
        de_AT, fr_FR, fr_CA, da_DK, jp_JP.
      example: en_US
    PreviewPayload:
      title: PreviewPayload
      type: object
      properties:
        locale:
          $ref: '#/components/schemas/Locale'
        data:
          title: Data
          type: object
          description: Template data
        content_type:
          allOf:
            - $ref: '#/components/schemas/ContentTypes'
          description: Can be either pdf, html or text
        template:
          title: Template
          type: string
          description: Template id
        style:
          title: Style
          type: string
          description: Style to use in the template
    PutStylePayload:
      title: PutStylePayload
      required:
        - content
      type: object
      properties:
        style_name:
          title: Style Name
          type: string
          description: Name of the style
        content:
          title: Content
          type: string
          description: Content of the style
    RenderPayload:
      title: RenderPayload
      required:
        - data
      type: object
      properties:
        locale:
          $ref: '#/components/schemas/Locale'
        data:
          title: Data
          type: object
          description: Data to use for rendering
        content_type:
          type: string
          allOf:
            - $ref: '#/components/schemas/ContentTypes'
          description: Can be either pdf, html or text
        ttl:
          title: Time to live
          type: string
          description: Time to live in days, will be kept indefinitely if not set.
    ValidationError:
      title: ValidationError
      required:
        - loc
        - msg
        - type
      type: object
      properties:
        loc:
          title: Location
          type: array
          items:
            anyOf:
              - type: string
              - type: integer
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
    StyleSheet:
      title: StyleSheet
      required:
        - name
      type: object
      properties:
        name:
          title: Name of the stylesheet
          type: string
    Template:
      title: Template
      required:
        - id
        - updated_at
        - locale
        - isDefault
      type: object
      properties:
        id:
          title: Human-readable identifier for the template
          type: string
        updated_at:
          title: Timestamp indicating the last change
          type: string
          format: timestamp
        locale:
          $ref: '#/components/schemas/Locale'
        isDefault:
          title: >-
            Defines if the template was modified for the tenant and locale or is
            the default version of the template
          type: boolean
    RenderResponse:
      title: RenderResponse
      type: object
      properties:
        content_type:
          title: Human-readable identifier for the template
          type: string
          allOf:
            - $ref: '#/components/schemas/ContentTypes'
        output:
          title: >-
            Depends on the `content_type`. Can be text, html, or base64 encoded
            PDF.
          type: string
        permanent_link:
          title: >-
            When a document is uploaded, the HTTP link referencing to the
            document will be specified in this property.
          type: string
        s3_params:
          title: >-
            If document was uploaded to S3, the parameters defining the document
            will be specified here.
          type: object
        vault_data_id:
          title: >-
            If document was uploaded to the data vault, the id of the data entry
            will be specified here.
