> ## Documentation Index
> Fetch the complete documentation index at: https://hoalulab.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cấp access token và refresh token

> Xác thực apiKey/apiSecret để lấy access token và refresh token (kèm thông tin hết hạn).



## OpenAPI

````yaml /vi/openapi/ssi.openapi.yaml post /api/v3/auth/token
openapi: 3.1.2
info:
  title: SSI FastConnect Open API
  version: 3.0.0
servers:
  - url: https://api.ssi.com.vn
    description: Production
security:
  - SsiBearerAuth: []
tags:
  - name: authentication
    description: Xác thực và quản lý token.
    x-group: Xác thực
  - name: account
    description: Thông tin tài khoản giao dịch.
    x-group: Tài khoản
  - name: market-data
    description: Dữ liệu thị trường.
    x-group: Dữ liệu thị trường
  - name: trading
    description: Giao dịch và quản lý lệnh.
    x-group: Giao dịch
  - name: conditional-orders
    description: Lệnh điều kiện.
    x-group: Lệnh điều kiện
paths:
  /api/v3/auth/token:
    post:
      tags:
        - authentication
      summary: Cấp access token và refresh token
      description: >-
        Xác thực apiKey/apiSecret để lấy access token và refresh token (kèm
        thông tin hết hạn).
      operationId: issueToken
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - apiKey
                - apiSecret
              properties:
                apiKey:
                  type: string
                  description: API key do SSI/FastConnect cấp cho ứng dụng.
                apiSecret:
                  type: string
                  description: API secret tương ứng với apiKey.
                otp:
                  type:
                    - string
                    - 'null'
                  description: >-
                    Mã OTP (SMS OTP hoặc SmartOTP) cần phải có nếu bạn muốn
                    token cấp ra có quyền thực hiện giao dịch. Trường hợp chỉ sử
                    dụng để truy vấn dữ liệu (data, query trading) thì không cần
                    truyền OTP.
                transactionId:
                  type:
                    - string
                    - 'null'
                  description: >-
                    Mã transaction trả về từ API `auth/requestOtp` khi tài khoản
                    dùng 2FA loại SmartOTP và đã kích hoạt luồng phê duyệt qua
                    ứng dụng iBoard.
      responses:
        '200':
          description: Thành công.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
              example:
                tokenType: Bearer
                accessToken: eyJhb...
                expiresAt: 1787238584
                refreshToken: eyJhb...
                refreshExpiresAt: 1787266484
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'
      security: []
components:
  schemas:
    TokenResponse:
      type: object
      required:
        - tokenType
        - accessToken
        - expiresAt
        - refreshToken
        - refreshExpiresAt
      properties:
        tokenType:
          description: Loại token.
          type: string
          example: Bearer
        accessToken:
          description: Access token dùng để gọi API.
          type: string
        expiresAt:
          description: Thời điểm access token hết hạn.
          type: integer
          format: int64
        refreshToken:
          description: Refresh token dùng để làm mới access token.
          type: string
        refreshExpiresAt:
          description: Thời điểm refresh token hết hạn.
          type: integer
          format: int64
    ErrorResponse:
      type: object
      properties:
        code:
          description: Mã kết quả hoặc mã xác thực giao dịch.
          type: string
        msg:
          description: Thông báo kết quả xử lý.
          type: string
  responses:
    BadRequest:
      description: Yêu cầu không hợp lệ.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Chưa được xác thực hoặc token không hợp lệ.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalError:
      description: Lỗi nội bộ máy chủ.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    SsiBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Access token lấy từ endpoint /api/v3/auth/token hoặc
        /api/v3/auth/refresh.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.