openapi: 3.0.3
info:
  title: Resources
  description: >-
    Manage your resources across your tenant. Once a resource is added to the
    relevant app, it can be specified in an authentication request in order to
    grant the user access to only this resource.
  version: ''
servers:
  - url: https://api.sbx.transmitsecurity.io/cis
    description: Sandbox environment
  - url: https://api.transmitsecurity.io/cis
    description: Production environment (US)
  - url: https://api.eu.transmitsecurity.io/cis
    description: Production environment (EU)
  - url: https://api.ca.transmitsecurity.io/cis
    description: Production environment (CA)
  - url: https://api.au.transmitsecurity.io/cis
    description: Production environment (AU)
security: []
paths:
  /v1/resources:
    post:
      operationId: createResource
      summary: Create resource
      description: >-
        Create a resource in a specific tenant. <br><br>**Required
        permissions**: `resources:create`, `apps:create`, `[appId]:create`.
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiCreateResourceInput'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                title: ApiCreatedResponse-createResource
                type: object
                required:
                  - result
                description: Resource created
                properties:
                  result:
                    $ref: '#/components/schemas/ApiResource'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestHttpError'
      security:
        - ClientAccessToken: []
    get:
      operationId: getResources
      summary: Get resources
      description: >-
        Retrieve all resources created in the tenant. <br><br>**Required
        permissions**: `resources:list`, `resources:read`.
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                title: ApiOkResponse-getResources
                type: object
                required:
                  - result
                description: ''
                properties:
                  result:
                    type: array
                    items:
                      $ref: '#/components/schemas/ApiResource'
      security:
        - ClientAccessToken: []
  /v1/resources/uri:
    get:
      operationId: getResourcesByUri
      summary: Get resource by URI
      description: >-
        Retrieve a specific resource by its URI. <br><br>**Required
        permissions**: `resources:read`, `apps:read`, `[appId]:read`.
      parameters:
        - name: resourceUri
          required: true
          in: query
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                title: ApiOkResponse-getResourcesByUri
                type: object
                required:
                  - result
                description: ''
                properties:
                  result:
                    $ref: '#/components/schemas/ApiResource'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestHttpError'
        '404':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceNotFoundHttpError'
      security:
        - ClientAccessToken: []
  /v1/resources/{resourceId}:
    put:
      operationId: updateResource
      summary: Update resource
      description: >-
        Update a specific resource. <br><br>**Required permissions**:
        `resources:edit`, `apps:edit`, `[appId]:edit`.
      parameters:
        - name: resourceId
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiUpdateResourceInput'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                title: ApiOkResponse-updateResource
                type: object
                required:
                  - result
                description: Resource updated
                properties:
                  result:
                    $ref: '#/components/schemas/ApiResource'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestHttpError'
        '404':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceNotFoundHttpError'
      security:
        - ClientAccessToken: []
    delete:
      operationId: deleteResource
      summary: Delete resource
      description: >-
        Delete a specific resource. <br><br>**Required permissions**:
        `resources:delete`, `apps:delete`, `[appId]:delete`.
      parameters:
        - name: resourceId
          required: true
          in: path
          schema:
            type: string
      responses:
        '204':
          description: ''
        '404':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceNotFoundHttpError'
        '409':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceInUseHttpError'
      security:
        - ClientAccessToken: []
components:
  schemas:
    ApiCreateResourceInput:
      type: object
      properties:
        name:
          type: string
          description: Name of the resource
          example: My Resource
        description:
          type: string
          description: Short description of the resource
        uri:
          type: string
          description: >-
            URI that identifies the resource, which is reflected in the audience
            (aud claim) of the access token
        access_token_ttl:
          type: number
          description: Access token expiration in seconds
        refresh_token_ttl:
          type: number
          description: Refresh token expiration in seconds
        max_refresh_rotate:
          type: number
          description: >-
            Absolute lifetime of a refresh token in seconds, after which it can
            no longer be used or rotated
      required:
        - name
        - uri
        - access_token_ttl
        - refresh_token_ttl
        - max_refresh_rotate
    BadRequestHttpError:
      type: object
      properties:
        message:
          example: Bad request
          type: array
          items:
            type: string
        error_code:
          type: number
          example: 400
      required:
        - message
        - error_code
    ApiResource:
      type: object
      properties:
        resource_id:
          type: string
          description: Resource ID
        tenant_id:
          type: string
          description: Tenant ID
        name:
          type: string
          description: Resource friendly name
        description:
          type: string
          description: Resource description
        uri:
          type: string
          description: Resource URI
        access_token_ttl:
          type: number
          description: Access token expiration in seconds
        refresh_token_ttl:
          type: number
          description: Refresh token expiration in seconds
        max_refresh_rotate:
          type: number
          description: >-
            Absolute lifetime of a refresh token in seconds, after which it can
            no longer be used or rotated
        created_at:
          format: date-time
          type: string
          description: Date the resource was created
        updated_at:
          format: date-time
          type: string
          description: Date the resource was last updated
      required:
        - resource_id
        - tenant_id
        - name
        - uri
        - access_token_ttl
        - refresh_token_ttl
        - max_refresh_rotate
        - created_at
        - updated_at
    ResourceNotFoundHttpError:
      type: object
      properties:
        message:
          type: string
          example: Resource does not exist in tenant
        error_code:
          type: number
          example: 404
      required:
        - message
        - error_code
    ApiUpdateResourceInput:
      type: object
      properties:
        name:
          type: string
          description: Name of the resource
          example: My Resource
        description:
          type: string
          description: Short description of the resource
        uri:
          type: string
          description: >-
            URI that identifies the resource, which is reflected in the audience
            (aud claim) of the access token
        access_token_ttl:
          type: number
          description: Access token expiration in seconds
        refresh_token_ttl:
          type: number
          description: Refresh token expiration in seconds
        max_refresh_rotate:
          type: number
          description: >-
            Absolute lifetime of a refresh token in seconds, after which it can
            no longer be used or rotated
    ResourceInUseHttpError:
      type: object
      properties:
        message:
          type: string
          example: Resource in use
        error_code:
          type: number
          example: 409
      required:
        - message
        - error_code
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http
    UserAccessToken:
      type: http
      description: >-
        A token returned upon end-user authentication, which provides access to
        resources and data for the user and app for which it was generated
      scheme: bearer
      bearerFormat: JWT
    AdminAccessToken:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: /oidc/token
          scopes: {}
      description: >-
        A token generated by a management application using the [token
        endpoint](/openapi/token.openapi/other/getaccesstoken). It provides
        access to all resources for the tenant and its apps
    ClientAccessToken:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: /oidc/token
          scopes: {}
      description: >-
        A token generated by an end-user application using the [token
        endpoint](/openapi/token.openapi/other/getaccesstoken). It provides
        access to resources and data on the tenant level or associated with the
        specific application (but not other apps in the tenant)
    OrgAdminAccessToken:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: /oidc/token
          scopes: {}
      description: >-
        A token returned upon B2B authentication for a user that has the
        organizationAdmin or organizationCreator role.
