openapi: 3.0.1
info:
  title: Glooh ECOOH API Specification
  version: 1.0.0
  description: >-
    On top of the iFrame (and the associated methods linked to it), a set of API
    are also accessible to login the user (generate the tokens) and retrieve the
    creatives informations.
  x-logo:
    url: ''
servers:
  - url: https://ecooh.staging.glooh.app/
    description: Ecooh staging endpoint
    x-last-modified: 1625686917853
paths:
  /auth/refresh:
    post:
      requestBody:
        content:
          application/json:
            schema:
              required:
                - token
              type: object
              properties:
                refresh_token:
                  description: >-
                    JWT access token you want to refresh. This token can't be
                    expired.
                  type: string
                  example: eyJ0eXAiOiJKV...
      tags:
        - Authentication
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      access_token:
                        type: string
                        example: eyJhbGciOiJI...
                      expires:
                        type: integer
                        example: 900
                      refresh_token:
                        type: string
                        example: Gy-caJMpmGTA...
          description: Successful request
        '401':
          $ref: '#/components/responses/UnauthorizedError'
      operationId: refresh
      summary: Refresh Token
      description: Refresh a Temporary Access Token.
  /auth/logout:
    post:
      requestBody:
        content:
          application/json:
            schema:
              required:
                - token
              type: object
              properties:
                refresh_token:
                  description: JWT access token you want to logout.
                  type: string
                  example: eyJ0eXAiOiJKV...
      tags:
        - Authentication
      responses:
        '200':
          description: Request successful
      operationId: logout
      summary: Log Out
      description: Log Out

  /users/me:
    get:
      tags:
        - Users
      parameters:
        - $ref: '#/components/parameters/Fields'
        - $ref: '#/components/parameters/Meta'
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Users'
          description: Successful request
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
      operationId: me
      summary: Retrieve Current User
      description: Retrieve the currently authenticated user.

  /assets/{id}:
    get:
      tags:
        - Assets
      parameters:
        - name: id
          description: The id of the file.
          schema:
            type: string
          in: path
          required: true
        - name: key
          description: The key of the asset size configured in settings.
          schema:
            type: string
          in: query
        - name: width
          description: Width of the file in pixels.
          schema:
            type: integer
          in: query
        - name: height
          description: Height of the file in pixels.
          schema:
            type: integer
          in: query
        - name: fit
          description: Fit of the file
          schema:
            enum:
              - crop
              - contain
              - inside
              - outside
            type: string
          in: query
        - name: withoutEnlargement
          description: No image upscale.
          schema:
            type: boolean
          in: query
        - name: quality
          description: Quality of compression.
          schema:
            maximum: 100
            minimum: 1
            type: integer
          in: query
        - name: download
          description: Download the asset to your computer
          schema:
            type: boolean
          in: query
      responses:
        '200':
          content:
            text/plain:
              schema:
                type: string
          description: Successful request
        '404':
          $ref: '#/components/responses/NotFoundError'
      operationId: getAsset
      summary: Get an Asset
      description: >-
        Image typed files can be dynamically resized and transformed to fit any
        need.
  /server/ping:
    get:
      tags:
        - Server
      responses:
        '200':
          content:
            application/text:
              schema:
                pattern: pong
                type: string
                example: pong
          description: Successful request
      operationId: ping
      summary: Ping
      description: Ping, pong. Ping.. pong.
  /items/creatives:
    get:
      tags:
        - Creatives
      parameters:
        - $ref: '#/components/parameters/Fields'
        - $ref: '#/components/parameters/Limit'
        - $ref: '#/components/parameters/Meta'
        - $ref: '#/components/parameters/Offset'
        - $ref: '#/components/parameters/Single'
        - $ref: '#/components/parameters/Sort'
        - $ref: '#/components/parameters/Filter'
        - $ref: '#/components/parameters/Search'
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schema/Creatives'
                      type: object
          description: Successful request
        '401':
          $ref: '#/components/responses/UnauthorizedError'
      security:
        - Auth: []
      operationId: readItemsCreatives
      summary: List Items
      description: List the creatives items.
  /items/creatives/{id}:
    get:
      tags:
        - Creatives
      parameters:
        - $ref: '#/components/parameters/Fields'
        - $ref: '#/components/parameters/Meta'
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    items:
                      $ref: '#/components/schema/Creatives'
          description: Successful request
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
      operationId: readSingleItemsCreatives
      summary: Retrieve an Item
      description: Retrieve a single creatives item by unique identifier.
    delete:
      tags:
        - Creatives
      responses:
        '200':
          description: Successful request
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
      operationId: deleteSingleItemsCreatives
      summary: Delete an Item
      description: Delete an existing creatives item.
    patch:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schema/ItemsCreatives'
              type: object
      tags:
        - Creatives
      parameters:
        - $ref: '#/components/parameters/Fields'
        - $ref: '#/components/parameters/Meta'
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    items:
                      $ref: '#/components/schema/ItemsCreatives'
          description: Successful request
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
      operationId: updateSingleItemsCreatives
      summary: Update an Item
      description: Update an existing creatives item.
  /custom/login:
    post:
      requestBody:
        content:
          application/json:
            schema:
              required:
                - user
                - password
              type: object
              properties:
                user:
                  description: >-
                    User id of the user you're retrieving the access token
                    for.
                  type: string
                  example: 12345
                password:
                  format: password
                  description: Password of the user.
                  type: string
                  example: password
              description: ''
            example: {user: "78748379-b2fa-41d8-bae7-3a852bfdf191", password: "X2-F]`%*Xh^exnZu"}
        description: ''
        required: false
      tags:
        - Authentication
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      access_token:
                        type: string
                        example: eyJhbGciOiJI...
                      expires:
                        type: integer
                        example: 900
                      refresh_token:
                        type: string
                        example: yuOJkjdPXMd...
          description: Successful authentification
      operationId: login
      summary: Retrieve a Temporary Access Token
      description: Retrieve a Temporary Access Token
    description: >-
      Each request to our backend needs to be authenticated via a JWT token.

      Before initialising the iFrame, a JWT token needs to be generated
      server-side.
    x-last-modified: 1625754581702
  /custom/createUser:
    post:
      requestBody:
        content:
          application/json:
            schema:
              required:
                - user
                - password
              type: object
              properties:
                user:
                  description: >-
                    GUID of the user
                  type: string
                  example: <GUID>
                password:
                  description: >-
                    Password of the user
                  type: string
                  example: <password>

      tags:
        - Users
      parameters:
        - $ref: null
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      accessToken:
                       type: string
                       example: eyJ ....
                      refreshToken:
                        type: string
                        example: mop....
                      expires:
                        example: 900000
                        type: integer
                      gloohId:
                        example: 5c0...
                example: ''
                externalDocs:
                  url: ''
                  description: ''
              example: {
    "data": {
       "access_token":"eyJh[...]qQ",
       "refreshToken": "...",
       "gloohId": "internal user guid",
       "expires":900000,
    }
}
          description: Successful request
          headers: {}
          links: {}
        '400':
          description: 400 is returned if no password is provided.
          x-last-modified: 1625755572396
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          description: If the user already exists in the database, error 403 is returned.
          x-last-modified: 1625755632216
        '404':
          $ref: '#/components/responses/NotFoundError'
      operationId: createUser
      summary: Create a User
      description: Create a new user.
    summary: Create a new user from the ECOOH platform to Glooh
    description: >
      This call should be done server-side.

      We suggest to create in your database-side for each user a 'password'
      (unique random string).

      When it's the first time using the platform, a call to create the user on
      Glooh's side needs to be done


      If the call was successfull - the user will automatically be logged in :

      * id,

      * refresh token,

      * access token,

      * expiry.
    x-last-modified: 1625755099839
components:
  schemas:
    Creatives:
      type: object
      properties:
        id:
          nullable: false
          type: integer
        status:
          nullable: false
          type: string
        user_created:
          oneOf:
            - format: uuid
              type: string
            - $ref: '#/components/schemas/Users'
          nullable: true
        date_created:
          nullable: true
          format: timestamp
          type: string
        user_updated:
          oneOf:
            - format: uuid
              type: string
            - $ref: '#/components/schemas/Users'
          nullable: true
        date_updated:
          nullable: true
          format: timestamp
          type: string
        template:
          oneOf:
            - type: integer
            - $ref: '#/components/schemas/ItemsTemplates'
          nullable: true
        fields:
          nullable: true
          type: array
          items:
            type: string
        creative_ecooh_id:
          nullable: true
          description: ID generated by Ecooh
          type: string
        thumbnail:
          oneOf:
            - format: uuid
              type: string
            - $ref: '#/components/schemas/Files'
          nullable: true
        media:
          oneOf:
            - format: uuid
              type: string
            - $ref: '#/components/schemas/Files'
          nullable: true
        media_cc:
          oneOf:
            - format: uuid
              type: string
            - $ref: '#/components/schemas/Files'
          nullable: true
      x-collection: creatives
    Files:
      type: object
      properties:
        id:
          description: Unique identifier for the file.
          type: string
          example: 8cbb43fe-4cdf-4991-8352-c461779cec02
        storage:
          description: >-
            Where the file is stored. Either `local` for the local filesystem or
            the name of the storage adapter (for example `s3`).
          type: string
          example: local
        filename_disk:
          description: >-
            Name of the file on disk. By default, Directus uses a random hash
            for the filename.
          type: string
          example: a88c3b72-ac58-5436-a4ec-b2858531333a.jpg
        filename_download:
          description: How you want to the file to be named when it's being downloaded.
          type: string
          example: avatar.jpg
        title:
          description: >-
            Title for the file. Is extracted from the filename on upload, but
            can be edited by the user.
          type: string
          example: User Avatar
        type:
          description: MIME type of the file.
          type: string
          example: image/jpeg
        folder:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Folders'
          nullable: true
          description: Virtual folder where this file resides in.
        uploaded_by:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Users'
          description: Who uploaded the file.
          example: 63716273-0f29-4648-8a2a-2af2948f6f78
        uploaded_on:
          format: date-time
          description: When the file was uploaded.
          type: string
          example: '2019-12-03T00:10:15+00:00'
        modified_by:
          nullable: true
          format: uuid
          type: string
        modified_on:
          nullable: false
          format: timestamp
          type: string
        charset:
          nullable: true
          description: Character set of the file.
          type: string
          example: binary
        filesize:
          description: Size of the file in bytes.
          type: integer
          example: 137862
        width:
          nullable: true
          description: Width of the file in pixels. Only applies to images.
          type: integer
          example: 800
        height:
          nullable: true
          description: Height of the file in pixels. Only applies to images.
          type: integer
          example: 838
        duration:
          nullable: true
          description: Duration of the file in seconds. Only applies to audio and video.
          type: integer
          example: 0
        embed:
          nullable: true
          description: Where the file was embedded from.
          type: string
        description:
          nullable: true
          description: Description for the file.
          type: string
        location:
          nullable: true
          description: >-
            Where the file was created. Is automatically populated based on EXIF
            data for images.
          type: string
        tags:
          nullable: true
          description: >-
            Tags for the file. Is automatically populated based on EXIF data for
            images.
          type: array
          items:
            type: string
        metadata:
          nullable: true
          description: IPTC, EXIF, and ICC metadata extracted from file
          type: object
        storage_divider: {}
      x-collection: directus_files
    Permissions:
      type: object
      properties:
        id:
          description: Unique identifier for the permission.
          type: integer
          example: 1
        role:
          nullable: true
          description: Unique identifier of the role this permission applies to.
          type: string
          example: 2f24211d-d928-469a-aea3-3c8f53d4e426
        collection:
          description: What collection this permission applies to.
          type: string
          example: customers
        action:
          description: What action this permission applies to.
          enum:
            - create
            - read
            - update
            - delete
          type: string
          example: create
        permissions:
          nullable: true
          description: >-
            JSON structure containing the permissions checks for this
            permission.
          type: object
        validation:
          nullable: true
          description: JSON structure containing the validation checks for this permission.
          type: object
        presets:
          nullable: true
          description: >-
            JSON structure containing the preset value for created/updated
            items.
          type: object
        fields:
          nullable: true
          description: CSV of fields that the user is allowed to interact with.
          type: array
          items:
            type: string
        limit:
          nullable: true
          description: Maximum amount of items the user can interact with at a time.
          type: number
      x-collection: directus_permissions
    Roles:
      type: object
      properties:
        id:
          description: Unique identifier for the role.
          type: string
          example: 2f24211d-d928-469a-aea3-3c8f53d4e426
        name:
          description: Name of the role.
          type: string
          example: Administrator
        icon:
          description: The role's icon.
          type: string
          example: verified_user
        description:
          nullable: true
          description: Description of the role.
          type: string
          example: Admins have access to all managed data within the system by default
        ip_access:
          description: >-
            Array of IP addresses that are allowed to connect to the API as a
            user of this role.
          type: array
          items:
            type: string
          example: []
        enforce_tfa:
          description: Whether or not this role enforces the use of 2FA.
          type: boolean
          example: false
        module_list:
          nullable: true
          description: Custom override for the admin app module bar navigation.
          type: array
          items:
            type: object
        collection_list:
          nullable: true
          description: Custom override for the admin app collection navigation.
          type: object
        admin_access:
          description: Admin role. If true, skips all permission checks.
          type: boolean
          example: false
        app_access:
          description: The users in the role are allowed to use the app.
          type: boolean
          example: true
        users:
          type: array
          items:
            oneOf:
              - format: uuid
                type: string
              - $ref: '#/components/schemas/Users'
      x-collection: directus_roles
    Users:
      type: object
      properties:
        id:
          description: Unique identifier for the user.
          type: string
          example: 63716273-0f29-4648-8a2a-2af2948f6f78
        first_name:
          description: First name of the user.
          type: string
          example: Admin
        last_name:
          description: Last name of the user.
          type: string
          example: User
        email:
          format: email
          description: Unique email address for the user.
          type: string
          example: admin@example.com
        password:
          description: Password of the user.
          type: string
        location:
          nullable: true
          description: The user's location.
          type: string
        title:
          nullable: true
          description: The user's title.
          type: string
        description:
          nullable: true
          description: The user's description.
          type: string
        tags:
          nullable: true
          description: The user's tags.
          type: array
          items:
            type: string
        avatar:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Files'
          nullable: true
          description: The user's avatar.
        language:
          description: The user's language used in Directus.
          type: string
          example: en-US
        theme:
          description: What theme the user is using.
          enum:
            - light
            - dark
            - auto
          type: string
          example: auto
        tfa_secret:
          nullable: true
          description: The 2FA secret string that's used to generate one time passwords.
          type: string
        status:
          description: Status of the user.
          enum:
            - active
            - invited
            - draft
            - suspended
            - deleted
          type: string
          example: active
        role:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Roles'
          description: Unique identifier of the role of this user.
          example: 2f24211d-d928-469a-aea3-3c8f53d4e426
        token:
          nullable: true
          description: Static token for the user.
          type: string
        last_access:
          nullable: true
          format: timestamp
          type: string
        last_page:
          nullable: true
          description: Last page that the user was on.
          type: string
          example: /my-project/settings/collections/a
        preferences_divider: {}
        admin_divider: {}
      x-collection: directus_users
  responses:
    NotFoundError:
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    format: int64
                    type: integer
                  message:
                    type: string
      description: 'Error: Not found.'
    UnauthorizedError:
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    format: int64
                    type: integer
                  message:
                    type: string
      description: 'Error: Unauthorized request'
  parameters:
    Id:
      name: id
      description: Index
      schema:
        type: integer
      in: path
      required: true
    UUId:
      name: id
      description: Unique identifier for the object.
      schema:
        type: string
        example: 8cbb43fe-4cdf-4991-8352-c461779cec02
      in: path
      required: true
    Search:
      name: search
      description: >-
        Filter by items that contain the given search query in one of their
        fields.
      schema:
        type: string
      in: query
      required: false
    Page:
      name: page
      description: Cursor for use in pagination. Often used in combination with limit.
      schema:
        type: integer
      in: query
      required: false
    Offset:
      name: offset
      description: How many items to skip when fetching data.
      schema:
        type: integer
      in: query
      required: false
    Single:
      name: single
      description: >-
        Return the result as if it was a single item. Useful for selecting a
        single item based on filters and search queries.
      schema:
        type: integer
      in: query
      required: false
    Sort:
      explode: false
      name: sort
      description: >
        How to sort the returned items. `sort` is a CSV of fields used to sort
        the fetched items. Sorting defaults to ascending (ASC) order but a minus
        sign (` - `) can be used to reverse this to descending (DESC) order.
        Fields are prioritized by their order in the CSV. You can also use a ` ?
        ` to sort randomly.
      schema:
        type: array
        items:
          type: string
      in: query
      required: false
    Meta:
      name: meta
      description: What metadata to return in the response.
      schema:
        type: string
      in: query
      required: false
    Limit:
      name: limit
      description: A limit on the number of objects that are returned.
      schema:
        type: integer
      in: query
      required: false
    Filter:
      name: filter
      description: Select items in collection by given conditions.
      schema:
        type: array
        items:
          pattern: >-
            ^(\[[^\[\]]*?\]){1}(\[(_eq|_neq|_lt|_lte|_gt|_gte|_in|_nin|_null|_nnull|_contains|_ncontains|_between|_nbetween|_empty|_nempty)\])?=.*?$
          type: string
      in: query
      required: false
    Fields:
      explode: false
      name: fields
      description: Control what fields are being returned in the object.
      schema:
        type: array
        items:
          type: string
      in: query
      required: false
    Mode:
      name: mode
      description: Controls if the API sets a cookie or returns a JWT on successful login.
      schema:
        enum:
          - jwt
          - cookie
        type: string
      in: query
      required: true
  securitySchemes:
    KeyAuth:
      type: apiKey
      name: access_token
      in: query
    Auth:
      type: apiKey
      name: Authorization
      in: header
  headers: {}
tags:
  - name: Authentication
    description: >-
      All events that happen within Glooh are tracked and stored. This gives you full accountability over everything
      that happens.
  - name: Users
    description: Users are what gives you access to the data.
    x-collection: directus_users

  - name: Assets
    description: >-
      Image typed files can be dynamically resized and transformed to fit any
      need.

  - name: Server
    description: >-
      Access to where Glooh runs. Allows you to make sure your server has
      everything needed to run the platform.
  - name: Creatives
    description: >-
      Access to where Glooh runs. Allows you to make sure your server has
      everything needed to run the platform.
    x-collection: creatives

security: []
