openapi: "3.0.2"
info:
  description: "Synergy! mail delivery api."
  version: "1.0.3"
  title: "Synergy! mail delivery api."
  termsOfService: ""
  x-audience: "https://mail.paas.crmstyle.com"
  contact:
    email: "api-tech-support@synergy101.jp"
  license:
    name: "Synergy"
    url: "https://form.synergy-marketing.co.jp/fcnts/euz/mailapi_agreement.html"
servers:
- url: "https://mail.paas.crmstyle.com/e"
paths:
  /tymail/v1/{user}/mail/deliveries/{taskId}:
    get:
      summary: "Get a delivery task status"
      operationId: "getDeliveryStatus"
      parameters:
      - $ref: "#/components/parameters/user"
      - $ref: "#/components/parameters/taskId"
      responses:
        200:
          description: "delivery status"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeliveryStatus"
        404:
          description: "no delivery task found"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:send"
    delete:
      summary: "Delete a delivery task"
      operationId: "deleteDeliveryTask"
      parameters:
      - $ref: "#/components/parameters/user"
      - $ref: "#/components/parameters/taskId"
      responses:
        200:
          description: "success"
        400:
          description: "bad request"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        404:
          description: "no delivery task found"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:send"
  /tymail/v1/{user}/mail/deliveries:
    post:
      summary: "start mail delivery"
      operationId: "startMailDelivery"
      parameters:
      - $ref: "#/components/parameters/user"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeliveryRequest"
      responses:
        200:
          description: "delivery status"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeliveryResponse"
        400:
          description: "bad request"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:send"
  /tymail/v1/{user}/mail/deliveries/{taskId}/send:
    post:
      summary: "start prepared mail delivery"
      operationId: "startPreparedMailDelivery"
      parameters:
      - $ref: "#/components/parameters/user"
      - $ref: "#/components/parameters/taskId"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PreparedDeliveryRequest"
      responses:
        200:
          description: "delivery status"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeliveryResponse"
        400:
          description: "bad request"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:send"
  /tymail/v1/{user}/mail/deliveries/new:
    post:
      summary: "create mail delivery setting"
      operationId: "createMailDeliverySetting"
      parameters:
      - $ref: "#/components/parameters/user"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeliverySettingRequest"
      responses:
        200:
          description: "delivery status"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeliveryResponse"
        400:
          description: "bad request"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:send"
  /tymail/v1/{user}/mail/deliveries/reserve/sendlists:
    post:
      summary: "create send list"
      operationId: "createSendList"
      parameters:
      - $ref: "#/components/parameters/user"
      requestBody:
        required: true
        content:
          text/csv:
            schema:
              type: "string"
      responses:
        200:
          description: "send list id"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateSendListResponse"
        400:
          description: "bad request"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        413:
          description: "entity too large"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:send"
  /tymail/v1/{user}/mail/deliveries/reserve/sendlists/{sendListId}:
    get:
      summary: "get send list"
      operationId: "getSendList"
      parameters:
      - $ref: "#/components/parameters/user"
      - $ref: "#/components/parameters/sendListId"
      responses:
        200:
          description: "send list"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SendList"
        404:
          description: "no send list found"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:send"
  /tymail/v1/{user}/mail/deliveries/reserve:
    post:
      summary: "reserve mail delivery"
      operationId: "reserveMailDelivery"
      parameters:
      - $ref: "#/components/parameters/user"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ReservingDeliveryRequest"
      responses:
        200:
          description: "delivery status"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeliveryResponse"
        400:
          description: "bad request"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:send"
  /tymail/v1/{user}/mail/deliveries/{taskId}/opens:
    get:
      summary: "Get the mail open results"
      operationId: "getDeliveryMailOpenResults"
      parameters:
      - $ref: "#/components/parameters/user"
      - $ref: "#/components/parameters/taskId"
      - $ref: "#/components/parameters/reportTermStart"
      - $ref: "#/components/parameters/reportTermEnd"
      responses:
        200:
          description: "mail open results"
          headers:
            Content-MD5:
              schema:
                type: "string"
                format: "byte"
          content:
            application/octet-stream:
              schema:
                type: "string"
                format: "binary"
        404:
          description: "no delivery task found"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:result"
  /tymail/v1/{user}/mail/deliveries/{taskId}/clicks:
    get:
      summary: "Get the mail click results"
      operationId: "getDeliveryMailClickResults"
      parameters:
      - $ref: "#/components/parameters/user"
      - $ref: "#/components/parameters/taskId"
      - $ref: "#/components/parameters/reportTermStart"
      - $ref: "#/components/parameters/reportTermEnd"
      responses:
        200:
          description: "mail click results"
          headers:
            Content-MD5:
              schema:
                type: "string"
                format: "byte"
          content:
            application/octet-stream:
              schema:
                type: "string"
                format: "binary"
        404:
          description: "no delivery task found"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:result"
  /tymail/v1/{user}/mail/deliveries/{taskId}/errors:
    get:
      summary: "Get the mail error results"
      operationId: "getDeliveryMailErrorResults"
      parameters:
      - $ref: "#/components/parameters/user"
      - $ref: "#/components/parameters/taskId"
      - $ref: "#/components/parameters/reportTermStart"
      - $ref: "#/components/parameters/reportTermEnd"
      responses:
        200:
          description: "mail error results"
          headers:
            Content-MD5:
              schema:
                type: "string"
                format: "byte"
          content:
            application/octet-stream:
              schema:
                type: "string"
                format: "binary"
        404:
          description: "no delivery task found"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:result"
  /tymail/v1/{user}/mail/deliveries/{taskId}/results:
    get:
      summary: "Get the mail results"
      operationId: "getDeliveryMailResults"
      parameters:
      - $ref: "#/components/parameters/user"
      - $ref: "#/components/parameters/taskId"
      - $ref: "#/components/parameters/reportTermStart"
      - $ref: "#/components/parameters/reportTermEnd"
      responses:
        200:
          description: "mail results"
          headers:
            Content-MD5:
              schema:
                type: "string"
                format: "byte"
          content:
            application/octet-stream:
              schema:
                type: "string"
                format: "binary"
        404:
          description: "no delivery task found"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:result"
  /tymail/v1/{user}/mail/deliveries/{taskId}/unsubscribes:
    get:
      summary: "Get unsubscription request results"
      operationId: "getDeliveryMailUnsubscriptionRequestResults"
      parameters:
      - $ref: "#/components/parameters/user"
      - $ref: "#/components/parameters/taskId"
      - $ref: "#/components/parameters/reportTermStart"
      - $ref: "#/components/parameters/reportTermEnd"
      responses:
        200:
          description: "mail unsubscription request results"
          headers:
            Content-MD5:
              schema:
                type: "string"
                format: "byte"
          content:
            application/octet-stream:
              schema:
                type: "string"
                format: "binary"
        404:
          description: "no delivery task found"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:result"
  /tymail/v1/{user}/mail/deliveries/errors/all:
    get:
      summary: "Get all mail error results"
      operationId: "getAllDeliveryMailErrorResults"
      parameters:
      - $ref: "#/components/parameters/user"
      - $ref: "#/components/parameters/reportTermStart"
      - $ref: "#/components/parameters/reportTermEnd"
      responses:
        200:
          description: "all mail error results"
          headers:
            Content-MD5:
              schema:
                type: "string"
                format: "byte"
          content:
            application/octet-stream:
              schema:
                type: "string"
                format: "binary"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:result"
  /tymail/v1/{user}/mail/deliveries/unsubscribes/all:
    get:
      summary: "Get all mail unsubscription request results"
      operationId: "getAllDeliveryMailUnsubscriptionRequestResults"
      parameters:
      - $ref: "#/components/parameters/user"
      - $ref: "#/components/parameters/reportTermStart"
      - $ref: "#/components/parameters/reportTermEnd"
      responses:
        200:
          description: "all mail unsubscription request results"
          headers:
            Content-MD5:
              schema:
                type: "string"
                format: "byte"
          content:
            application/octet-stream:
              schema:
                type: "string"
                format: "binary"
        500:
          description: "internal server error"
      security:
      - mail_oauth:
        - "mail:result"
components:
  parameters:
    user:
      in: "path"
      name: "user"
      required: true
      description: "user name"
      schema:
        type: "string"
        minLength: 3
    taskId:
      in: "path"
      name: "taskId"
      required: true
      description: "delivery task id"
      schema:
        type: "integer"
        format: "int64"
    sendListId:
      in: "path"
      name: "sendListId"
      required: true
      description: "send list id"
      schema:
        type: "integer"
        format: "int64"
    reportTermStart:
      in: "query"
      name: "start"
      required: false
      description: "report term start"
      schema:
        type: "string"
        format: "date-time"
    reportTermEnd:
      in: "query"
      name: "end"
      required: false
      description: "report term end"
      schema:
        type: "string"
        format: "date-time"
  schemas:
    DeliveryRequest:
      type: "object"
      properties:
        requestId:
          type: "string"
          minLength: 1
        test:
          type: "boolean"
          default: false
        encode:
          type: "string"
          enum:
            - "UTF-8"
            - "ISO-2022-JP"
          default:
            "UTF-8"
        trackingDomain:
          type: "string"
          description: "If you want to use this parameter, please contact support."
        trackingDomainSslReady:
          type: "boolean"
        fromName:
          type: "string"
          minLength: 1
          maxLength: 120
        fromAddress:
          type: "string"
          nullable: false
          minLength: 1
          maxLength: 256
        replyAddress:
          type: "string"
          minLength: 1
          maxLength: 256
        subject:
          type: "string"
          nullable: false
          minLength: 1
          maxLength: 120
        preheader:
          type: "string"
        bodyText:
          type: "string"
          minLength: 1
        bodyHtml:
          type: "string"
          minLength: 1
        deliveryMailAddressPropertyName:
          type: "string"
          nullable: false
          minLength: 1
        count:
          type: "integer"
          nullable: false
        deliveryData:
          type: "array"
          nullable: false
          items:
            type: object
            additionalProperties:
              type: "string"
        oneClickUnsubscriptionReady:
          type: "boolean"
    PreparedDeliveryRequest:
      type: "object"
      properties:
        requestId:
          type: "string"
          minLength: 1
        test:
          type: "boolean"
          default: false
        trackingDomain:
          type: "string"
          description: "If you want to use this parameter, please contact support."
        trackingDomainSslReady:
          type: "boolean"
        count:
          type: "integer"
          nullable: false
        deliveryData:
          type: "array"
          nullable: false
          items:
            type: object
            additionalProperties:
              type: "string"
        oneClickUnsubscriptionReady:
          type: "boolean"
    DeliverySettingRequest:
      type: "object"
      properties:
        encode:
          type: "string"
          enum:
            - "UTF-8"
            - "ISO-2022-JP"
          default:
            "UTF-8"
        trackingDomain:
          type: "string"
          description: "If you want to use this parameter, please contact support."
        trackingDomainSslReady:
          type: "boolean"
        fromName:
          type: "string"
          minLength: 1
          maxLength: 120
        fromAddress:
          type: "string"
          nullable: false
          minLength: 1
          maxLength: 256
        replyAddress:
          type: "string"
          minLength: 1
          maxLength: 256
        subject:
          type: "string"
          nullable: false
          minLength: 1
          maxLength: 120
        preheader:
          type: "string"
        bodyText:
          type: "string"
          minLength: 1
        bodyHtml:
          type: "string"
          minLength: 1
        deliveryMailAddressPropertyName:
          type: "string"
          nullable: false
          minLength: 1
    DeliveryResponse:
      type: "object"
      properties:
        deliveryTaskId:
          type: "integer"
          format: "int64"
        textClickFeedbacks:
          type: "array"
          items:
            $ref: "#/components/schemas/ClickFeedback"
        htmlClickFeedbacks:
          type: "array"
          items:
            $ref: "#/components/schemas/ClickFeedback"
    ClickFeedback:
      type: "object"
      properties:
        id:
          type: "integer"
          format: "int64"
        url:
          type: "string"
    DeliveryStatus:
      type: "object"
      properties:
        deliveryTaskId:
          type: "integer"
          format: "int64"
        total:
          type: "integer"
          format: "int64"
        sent:
          type: "integer"
          format: "int64"
        status:
          type: "string"
          description: "delivery status"
          enum:
          - "RESERVED"
          - "SENDING"
          - "COMPLETED"
          - "ERROR"
    CreateSendListResponse:
      type: "object"
      properties:
        sendListId:
          type: "integer"
          format: "int64"
    SendList:
      type: "object"
      properties:
        sendListId:
          type: "integer"
          format: "int64"
        status:
          type: "string"
          enum:
          - "SUCCESS"
          - "FAIL"
          - "PROCESSING"
          - "EXPIRED"
        expirationDateTime:
          type: "string"
          format: "date-time"
        rowCount:
          type: "integer"
          format: "int64"
        errorMessage:
          type: "string"
        deliveryTaskId:
          type: "integer"
          format: "int64"
    ReservingDeliveryRequest:
      type: "object"
      properties:
        sendListId:
          type: "integer"
          format: "int64"
        requestId:
          type: "string"
          minLength: 1
        encode:
          type: "string"
          enum:
          - "UTF-8"
          - "ISO-2022-JP"
          default: "UTF-8"
        fromAddress:
          type: "string"
          nullable: false
          minLength: 1
          maxLength: 256
        fromName:
          type: "string"
          minLength: 1
          maxLength: 120
        replyAddress:
          type: "string"
          minLength: 1
          maxLength: 256
        preheader:
          type: "string"
        subject:
          type: "string"
          nullable: false
          minLength: 1
          maxLength: 120
        bodyText:
          type: "string"
          minLength: 1
        bodyHtml:
          type: "string"
          minLength: 1
        deliveryMailAddressPropertyName:
          type: "string"
          nullable: false
          minLength: 1
        trackingDomain:
          type: "string"
          description: "If you want to use this parameter, please contact support."
        trackingDomainSslReady:
          type: "boolean"
        sendDateTime:
          type: "string"
          format: "date-time"
        oneClickUnsubscriptionReady:
          type: "boolean"
    ErrorResponse:
      type: "object"
      properties:
        errors:
          type: "array"
          items:
            $ref: "#/components/schemas/Error"
    Error:
      type: "object"
      properties:
        code:
          type: "string"
        property:
          type: "string"
        message:
          type: "string"
  securitySchemes:
    mail_oauth:
      type: oauth2
      description: mail auth
      flows:
        clientCredentials:
          tokenUrl: "https://auth.paas.crmstyle.com/oauth2/token"
          refreshUrl: "https://auth.paas.crmstyle.com/oauth2/token"
          scopes:
            mail:send: "delivery"
            mail:result: "get the delivery results"
