Spare Token API

The Token API from Spare — 2 operation(s) for token.

OpenAPI Specification

spare-token-api-openapi.yml Raw ↑
openapi: 3.0.1
info:
  title: Information Account Token API
  description: Spare account information API documentation
  termsOfService: https://terms.tryspare.com/en
  contact:
    name: Spare Technologies WLL.
    email: hello@tryspare.com
  license:
    name: Spare Technologies WLL.
  version: '1.0'
security:
- Bearer: []
tags:
- name: Token
paths:
  /api/v1.0/authentication/Token:
    get:
      tags:
      - Token
      summary: Generates an API authentication token using the provided API credentials.
      description: "**Unique resource name:** api_authentication.v1.token\r\n            \r\nThis endpoint authenticates an API keys by validating the provided API credentials.\r\nUpon successful authentication, an access token is generated and returned.\r\n            \r\n**Authentication Process:**\r\n- The `app-id` and `x-api-key` headers must contain valid credentials.\r\n- If authentication is successful, a signed JSON Web Token (JWT) is issued.\r\n- If authentication fails due to invalid credentials, a `401 Unauthorized` response is returned.\r\n            \r\n**Security Considerations:**\r\n- The API key (`x-api-key`) should be kept confidential.\r\n- The generated JWT should be used for subsequent authenticated requests."
      parameters:
      - name: app-id
        in: header
        description: The unique identifier of the API keys.
        required: true
        schema:
          type: string
      - name: x-api-key
        in: header
        description: The API key associated with the API keys.
        required: true
        schema:
          type: string
      responses:
        '401':
          description: Returned if the API credentials (`app-id` and `x-api-key`) are incorrect or unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '500':
          description: Internal Server Error
        '200':
          description: Successfully generated an API authentication token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonWebTokenResponseModel'
  /api/v1.0/authentication/Refresh:
    get:
      tags:
      - Token
      summary: Refreshes an API authentication token using a valid refresh token.
      description: "**Unique resource name:** api_authentication.v1.refresh\r\n            \r\nThis endpoint allows clients to obtain a new access token by providing a valid refresh token.\r\nThe refresh token must be issued by the authentication service and must not be expired.\r\n            \r\n**Authentication Process:**\r\n- The `refresh-token` header must contain a valid refresh token.\r\n- If the refresh token is valid, a new access token is issued.\r\n- If the refresh token is invalid or expired, a `401 Unauthorized` response is returned.\r\n            \r\n**Security Considerations:**\r\n- Refresh tokens should be stored securely and not shared."
      parameters:
      - name: refresh-token
        in: header
        description: The refresh token used to obtain a new access token.
        required: true
        schema:
          type: string
      responses:
        '401':
          description: Returned if the refresh token is incorrect, expired, or unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '500':
          description: Internal Server Error
        '200':
          description: Successfully generated a new API authentication token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonWebTokenResponseModel'
components:
  schemas:
    ProblemDetails:
      type: object
      properties:
        type:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        status:
          type: integer
          format: int32
          nullable: true
        detail:
          type: string
          nullable: true
        instance:
          type: string
          nullable: true
      additionalProperties: {}
    JsonWebTokenResponseModel:
      type: object
      properties:
        type:
          type: string
          nullable: true
          readOnly: true
        access_token:
          type: string
          nullable: true
        expires_in:
          type: integer
          format: int32
        refresh_token:
          type: string
          nullable: true
        refresh_expires_in:
          type: integer
          format: int32
      additionalProperties: false
  securitySchemes:
    Bearer:
      type: apiKey
      description: Please enter into field the word 'Bearer' followed by a space and JWT
      name: Authorization
      in: header