openapi: 3.0.3
info:
  title: Flinks API
  description: |
    Flinks API provides financial data connectivity, enrichment, and payment solutions.

    ## Authentication
    Endpoints require authentication using `flinks-auth-key` header (Bearer token).

    For more information, visit: https://docs.flinks.com
  version: 3.0.0
  contact:
    name: Flinks Support
    url: https://www.flinks.com/contact/sales
  termsOfService: https://www.flinks.com


tags:
  - name: Authorization
    description: Endpoints for generating authorization tokens and authenticating requests
  - name: Enrich - Consumer Attributes
    description: Consumer financial attribute analysis and credit risk assessment

servers:
  - url: https://www.{baseurl}.com
    description: Flinks Pay Production
    variables:
      baseurl:
        default: "{baseurl}"
        description: The base URI for the environment (e.g. flinks)

paths:
  /api/v1/reports: {"get": {"tags": ["Reports"], "summary": "List reports", "description": "List the reports generated for your client, filtered by type and period, then use the returned id with the get-report endpoint to obtain a download link.", "operationId": "listReports", "parameters": [{"name": "x-api-key", "in": "header", "required": true, "description": "API key issued by Flinks.", "schema": {"type": "string"}}, {"name": "x-client-id", "in": "header", "required": true, "description": "Your Flinks client ID.", "schema": {"type": "string"}}, {"name": "filteringTypes", "in": "query", "required": false, "description": "Filter by report type; repeat the parameter for multiple values.", "schema": {"type": "array", "items": {"type": "string", "enum": ["ClientSettlement", "DailyProgress", "DailyGEft", "InternalMonthlyTransaction"]}}}, {"name": "startDate", "in": "query", "required": false, "description": "Start of the report period range in ISO 8601 format.", "schema": {"type": "string", "format": "date-time"}}, {"name": "endDate", "in": "query", "required": false, "description": "End of the report period range in ISO 8601 format.", "schema": {"type": "string", "format": "date-time"}}, {"name": "page", "in": "query", "required": false, "schema": {"type": "integer"}}, {"name": "pageSize", "in": "query", "required": false, "schema": {"type": "integer"}}], "responses": {"200": {"description": "A paginated list of reports.", "content": {"application/json": {"schema": {"type": "object", "properties": {"total": {"type": "integer"}, "totalPages": {"type": "integer"}, "items": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "string", "format": "uuid"}, "name": {"type": "string"}, "reportType": {"type": "string"}, "totalAmount": {"type": "number"}, "totalTransactions": {"type": "integer"}, "createdAt": {"type": "string", "format": "date-time"}, "periodStart": {"type": "string", "format": "date-time"}, "periodEnd": {"type": "string", "format": "date-time"}}}}}}}}}, "400": {"description": "Bad Request"}, "401": {"description": "Unauthorized"}}}}
  /api/v1/authorize:
   post:
      tags:
        - Authorization
      summary: Authorize
      description: Authorize and generate an access token.

      operationId: authorize
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                grant_type:
                  type: string
                  description: The type of grant (e.g., client_credentials).
                Username:
                  type: string
                  description: The username provided during onboarding.
                Password:
                  type: string
                  description: The password provided during onboarding.
              example: {}
      responses:
        "200":
          description: Result
          content:
            application/json:
              schema:
                type: object
                properties:
                  access_token:
                    type: string
                    description: The access token.
                  token_type:
                    type: string
                    description: The type of token.
                  expires_in:
                    type: integer
                    description: Expiration time in seconds.
        "400":
          description: Bad Request
  
  /api/v1/sessions/sendrequest:
    post:
      tags:
        - Pay
      summary: Initiating a session
      description: Use the /Sessions/Initiate endpoint to allow a customer to complete the payments flow.
      operationId: sendRequest
      parameters:
        - name: BaseURI
          in: header
          required: false
          description: The unique environment that you are making the API call from. Provided during onboarding.
          schema:
            type: string
        - name: Bearer Token
          in: header
          required: false
          description: The access_token received previously in a completed authorize call.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                ReferenceId:
                  type: string
                  description: A customizable UserId that must be provided to identify the transaction throughout the process.
                amount:
                  type: string
                  description: The amount that is being requested from the user to pay.
                customerName:
                  type: string
                  description: The first and last name of the user being requested to pay.
                customerEmail:
                  type: string
                  description: The email of the user being requested to pay.
                clientURIs:
                  type: string
                  description: A list of URLs that will be utilized to display the app.
              example: {}
      responses:
        "200":
          description: Result
          content:
            application/json:
              schema:
                type: object
                properties:
                  sessionId:
                    type: string
                    description: The unique ID of the generated session.
                    example: "6c376ebd-1670-49e3-9148-26c1360f98d3"
                  referenceId:
                    type: string
                    description: The reference ID that was provided in the request.
                    example: "User1234"

  /api/v1/paymentrequests/{requestId}:
    get:
      tags:
        - Pay
      summary: Get the status of a payment request
      description: Use this endpoint to check on the status of a payment request by providing the requestId of a previously generated payment.
      operationId: getPaymentRequestStatus
      parameters:
        - name: requestId
          in: path
          required: true
          description: Unique GUID representing a previously generated payment transaction.
          schema:
            type: string
        - name: BaseURI
          in: header
          required: false
          description: The unique environment that you are making the API call from. Provided during onboarding.
          schema:
            type: string
        - name: BearerToken
          in: header
          description: Bearer (plus the access_token received previously in a completed authorize call).
          schema:
            type: string
      responses:
        "200":
          description: Result
          content:
            application/json:
              schema:
                type: object
                properties:
                  requestId:
                    type: string
                  status:
                    type: string
                    description: Current status of the payment request.
                  ReferenceId:
                    type: string
                  PaymentLink:
                    type: string
        "400":
          description: Result

  /api/v1/paymentrequests:
    post:
      tags:
        - Pay
      summary: Create a payment request
      description: Use the /PaymentRequests endpoint as the final step to ensure you can have a user complete the payments flow.
      operationId: createPaymentRequest
      parameters:
        - name: BaseURI
          in: header
          required: false
          description: The unique environment that you are making the API call from. Provided during onboarding.
          schema:
            type: string
        - name: BearerToken
          in: header
          description: Bearer (plus the access_token received previously in a completed authorize call).
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                sessionId:
                  type: string
                  description: GUID representing the unique ID of the generated session within the Flinks system.
              example: {}
      responses:
        "200":
          description: Result
          content:
            application/json:
              schema:
                type: object
                properties:
                  requestId:
                    type: string
                    description: The unique ID of the payment request.
        "400":
          description: Result

  /api/v1/sessions/initiate:
    post:
      tags:
        - Pay
      summary: Initiating a session
      description: Use the /Sessions/Initiate endpoint to allow a customer to complete the payments flow.
      operationId: initiateSession
      parameters:
        - name: BaseURI
          in: header
          required: false
          description: The unique environment that you are making the API call from. Provided during onboarding.
          schema:
            type: string
        - name: Bearer Token
          in: header
          required: false
          description: The access_token received previously in a completed authorize call.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                ReferenceId:
                  type: string
                  description: A customizable UserId that must be provided to identify the transaction throughout the process.
                amount:
                  type: string
                  description: The amount that is being requested from the user to pay.
                customerName:
                  type: string
                  description: The first and last name of the user being requested to pay.
                customerEmail:
                  type: string
                  description: The email of the user being requested to pay.
                clientURIs:
                  type: string
                  description: A list of URLs that will be utilized to display the app.
              example: {}
      responses:
        "200":
          description: Result
          content:
            application/json:
              schema:
                type: object
                properties:
                  sessionId:
                    type: string
                    description: The unique ID of the generated session.
                    example: "6c376ebd-1670-49e3-9148-26c1360f98d3"
                  referenceId:
                    type: string
                    description: The reference ID that was provided in the request.
                    example: "User1234"
        "400":
          description: Result

components:
  securitySchemes:
    FlinksAuthKey:
      type: apiKey
      in: header
      name: flinks-auth-key
    OptionalApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Optional security feature (must be enabled by Flinks). Contact your Flinks representative to activate.

  schemas:
    Login:
      type: object
      description: End user's technical login information
      properties:
        Id:
          type: string
          format: uuid
        Username:
          type: string
        IsScheduledRefresh:
          type: boolean
          default: false
        LastRefresh:
          type: string
          format: date-time
        Type:
          type: string

    Link:
      type: object
      properties:
        rel:
          type: string
          description: Relationship type of the link
        href:
          type: string
          description: Endpoint path
        example:
          type: string
          nullable: true

    SecurityChallenge:
      type: object
      properties:
        Type:
          type: string
          description: Type of security challenge (e.g., QuestionAndAnswer)
          example: QuestionAndAnswer
        Prompt:
          type: string
          description: The security question to present to the user
          example: What shape do people like most?

security: []
