{
  "openapi": "3.0.4",
  "x-stoplight": {
    "id": "b39anb7vgvfvi"
  },
  "info": {
    "title": "Identity",
    "version": "v1"
  },
  "paths": {
    "/api/v1/auth/session": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Create a new session for Non-Interactive User",
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Business.Models.Request.CreateSessionRequestModel"
              },
              "examples": {
                "Example 1": {
                  "value": {
                    "client_id": "cli_YOUR_CLIENT_ID",
                    "client_secret": "sec_YOUR_CLIENT_SECRET"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Business.Models.Response.CreateSessionResponseModel"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "session": "77444f76971e41268bc7d2804b31c73f",
                      "expires_in": 3600
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails"
                }
              }
            }
          }
        },
        "x-stoplight": {
          "id": "r3r4j2yi9sfyl"
        },
        "description": "This API allows applications to authenticate a non-interactive user and retrieve a session token. \r\n\r\n ⚠️ **Important Notes** \r\n \r\n    - Your **Application** must be associated with a **Merchant**. \r\n    - The **client_secret** must be used carefully. After **3 failed attempts**, the account will be **locked**. \r\n    - The session token is **valid for 5 minutes**. After expiration, a new session must be requested.",
        "operationId": "create-a-new-session-for-non-interactive-user"
      }
    },
    "/api/v1/oauth/token": {
      "post": {
        "tags": [
          "OAuth"
        ],
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/IdentityClientApi.Models.Request.TokenRequestModel"
              },
              "examples": {
                "Example 1": {
                  "value": {
                    "client_id": "client_YOUR_CLIENT_ID",
                    "client_secret": "secret_YOUR_CLIENT_SECRET",
                    "grant_type": "client_credentials"
                  }
                }
              }
            }
          },
          "description": "You can use only '**client_credentials**' as a grant type."
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Business.Models.Response.TokenResponseModel"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "access_token": "20002A6F33C5277D98DC00A6E0493AEFE3F99823E62DFA9AAFB1D2F952420F3B-1",
                      "expires_in": 3600,
                      "token_type": "Bearer",
                      "scope": "accounting.read accounting.write banking.read banking.write"
                    }
                  }
                }
              }
            }
          }
        },
        "x-stoplight": {
          "id": "y0uvwj34tfrjf"
        },
        "x-internal": false,
        "summary": "Generate OAuth Token",
        "description": "Upon successful execution of this method, you will receive an **Opaque OAuth 2.0 Token.** \r\nThis token grants authorization to access **all available endpoints.**\r\n\r\n**Important:** The token has an **expiration time of 1 hour** from the moment of issuance. You must refresh or re-acquire a new token after this period to maintain access.",
        "security": [],
        "operationId": "generate-oauth-token"
      }
    }
  },
  "components": {
    "schemas": {
      "Business.Models.Request.CreateSessionRequestModel": {
        "type": "object",
        "properties": {
          "client_id": {
            "type": "string",
            "nullable": true,
            "example": "cli_YOUR_CLIENT_ID"
          },
          "client_secret": {
            "type": "string",
            "nullable": true,
            "example": "sec_YOUR_CLIENT_SECRET"
          }
        },
        "additionalProperties": false,
        "x-stoplight": {
          "id": "z8rixffu4z05s"
        },
        "x-examples": {
          "Example 1": {
            "client_id": "cli_YOUR_CLIENT_ID",
            "client_secret": "sec_YOUR_CLIENT_SECRET"
          }
        }
      },
      "Business.Models.Response.CreateSessionResponseModel": {
        "type": "object",
        "additionalProperties": false,
        "x-stoplight": {
          "id": "nulcmztj9zxw9"
        },
        "properties": {
          "session": {
            "type": "string",
            "example": "77444f76971e41268bc7d2804b31c73f",
            "nullable": true
          },
          "expires_in": {
            "type": "integer",
            "format": "int32",
            "example": 3600
          }
        },
        "x-examples": {
          "Example 1": {
            "session": "77444f76971e41268bc7d2804b31c73f",
            "expires_in": 3600
          }
        }
      },
      "Business.Models.Response.TokenResponseModel": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string",
            "nullable": true
          },
          "expires_in": {
            "type": "integer",
            "format": "int32"
          },
          "token_type": {
            "type": "string",
            "nullable": true
          },
          "expires_on": {
            "type": "integer",
            "format": "int64"
          },
          "scope": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "x-stoplight": {
          "id": "bvsq52kwsfv5v"
        }
      },
      "IdentityClientApi.Models.Request.TokenRequestModel": {
        "type": "object",
        "additionalProperties": false,
        "x-stoplight": {
          "id": "3e358tgamiz7d"
        },
        "x-examples": {
          "Example 1": {
            "client_id": "client_2073a17f5bd642419f548a2c4aee5b3f",
            "client_secret": "secret_048903361b4ffc1d394d686774c2312ef2340ab37092c644d195752f2b5b9437",
            "grant_type": "client_credentials"
          }
        },
        "properties": {
          "client_id": {
            "type": "string",
            "example": "client_2073a17f5bd642419f548a2c4aee5b3f",
            "nullable": true
          },
          "client_secret": {
            "type": "string",
            "example": "secret_048903361b4ffc1d394d686774c2312ef2340ab37092c644d195752f2b5b9437",
            "nullable": true
          },
          "grant_type": {
            "type": "string",
            "example": "client_credentials",
            "nullable": true
          }
        }
      },
      "Microsoft.AspNetCore.Mvc.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": {},
        "x-stoplight": {
          "id": "e10bkzq4g46nc"
        }
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "description": "Input your Bearer token to access this API",
        "scheme": "Bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "Bearer": [],
      "Basic": []
    }
  ],
  "servers": [
    {
      "url": "https://demo-api-gateway.mypos.com",
      "description": "Demo"
    },
    {
      "url": "https://api-gateway.mypos.com",
      "description": "Prod"
    }
  ]
}
