---
title: Generate a Bearer Token
slug: api/generate-a-bearer-token
createdAt: 2026-10-21T00:47:27.015Z
---

{
  "id": "9C-5hINYmnwQnTFwiYXQq",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://sand-api.monoova.com/au/security/oauth-v1/Token",
    "servers": [
      {
        "url": "https://sand-api.monoova.com/au/security/oauth-v1/Token",
        "description": "Sandbox URL"
      },
      {
        "url": "https://api.monoova.com/au/security/oauth-v1/Token",
        "description": "Production URL"
      }
    ],
    "name": "Generate a Bearer Token",
    "description": "<p>Bearer tokens are used for authentication when calling the PayTo and Card Payment endpoints. These are short-lived tokens that expire after 24 hours.</p>\n<p>The basic authentication used when calling the Generate a Bearer Token endpoint is slightly different to other endpoints. You will need to supply both the username and password parameters when authenticating:</p>\n<ul>\n<li><strong>Username</strong>: your mAccount number.</li>\n<li><strong>Password</strong>: your API key.</li>\n</ul>\n<p>You can obtain both from the Monoova portal.</p>\n<p>After 10 failed authentication attempts, your account is blocked. To unlock your account, roll your API key in the Monoova portal. Rolling your API key affects your existing API integration, so you need to update the API key across your environment.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "basicAuth",
          "name": "basicAuth",
          "kind": "optional",
          "type": "http",
          "description": "<p>To authenticate using basic authentication, pass your mAccount number as the username and your API key as the password.</p>",
          "scheme": "basic"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "OK. Returns the bearer token.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "The generated bearer token.",
            "customType": "TokenResponse",
            "schema": [
              {
                "name": "token",
                "kind": "optional",
                "type": "string",
                "description": "<p>Bearer token (JWT). Pass it in the <code>Authorization</code> header as <code>Bearer &#x3C;token></code> when you call the Monoova PayTo endpoints. The token expires 60 minutes after it is generated.</p>",
                "example": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjEwMDQ4MDAsImV4cCI6MTc2MTAwODQwMH0.x1gXndPwqQy7R5IPDu2aND26vkx3SZ0GU_LS-VOg7RA",
                "default": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjEwMDQ4MDAsImV4cCI6MTc2MTAwODQwMH0.x1gXndPwqQy7R5IPDu2aND26vkx3SZ0GU_LS-VOg7RA",
                "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"
              }
            ],
            "modelRef": "#/components/schemas/TokenResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "<p>Bad Request. The request is invalid. Check <code>errors</code> for details.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "example": "{\"traceId\":\"4ea61012-2d9b-413d-a5b4-90ad69a68741\",\"errors\":[{\"errorCode\":\"VALIDATION_ERROR\",\"errorMessage\":\"One or more validation failures have occurred\"}]}",
            "description": "Details of the errors returned when a request fails.",
            "customType": "ErrorResponse",
            "schema": [
              {
                "name": "traceId",
                "kind": "optional",
                "type": "string",
                "nullable": true,
                "description": "Unique ID for logging.",
                "example": "4ea61012-2d9b-413d-a5b4-90ad69a68741",
                "default": "4ea61012-2d9b-413d-a5b4-90ad69a68741",
                "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "array",
                "nullable": true,
                "description": "List of errors that occurred while processing the request.",
                "modelRef": "#/components/schemas/ErrorDto",
                "customType": "ErrorDto[]",
                "schema": [
                  {
                    "name": "errorCode",
                    "kind": "optional",
                    "type": "string",
                    "nullable": true,
                    "description": "Monoova error code.",
                    "example": "VALIDATION_ERROR",
                    "default": "VALIDATION_ERROR",
                    "pattern": "^[A-Z0-9_]{1,64}$"
                  },
                  {
                    "name": "errorMessage",
                    "kind": "optional",
                    "type": "string",
                    "nullable": true,
                    "description": "<p>Detailed description of the error, which may include information from the request.</p>",
                    "example": "One or more validation failures have occurred",
                    "default": "One or more validation failures have occurred",
                    "pattern": "^.+$"
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/ErrorResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "<p>Unauthorized. Authentication failed because the mAccount number or API key is missing or incorrect. After 10 failed authentication attempts, your account is blocked and requests return <code>401</code> until you roll your API key in the Monoova portal.</p>",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "500",
        "description": "Internal Server Error. An unexpected error occurred. Try again later and contact Monoova support if the problem persists.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "example": "{\"traceId\":\"f1a7fbd7-ca39-4b98-b247-f4e0e004f152\",\"errors\":[{\"errorCode\":\"UNEXPECTED_ERROR\",\"errorMessage\":\"Internal server error. Please contact Monoova support.\"}]}",
            "description": "Details of the errors returned when a request fails.",
            "customType": "ErrorResponse",
            "schema": [
              {
                "name": "traceId",
                "kind": "optional",
                "type": "string",
                "nullable": true,
                "description": "Unique ID for logging.",
                "example": "4ea61012-2d9b-413d-a5b4-90ad69a68741",
                "default": "4ea61012-2d9b-413d-a5b4-90ad69a68741",
                "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "array",
                "nullable": true,
                "description": "List of errors that occurred while processing the request.",
                "modelRef": "#/components/schemas/ErrorDto",
                "customType": "ErrorDto[]",
                "schema": [
                  {
                    "name": "errorCode",
                    "kind": "optional",
                    "type": "string",
                    "nullable": true,
                    "description": "Monoova error code.",
                    "example": "VALIDATION_ERROR",
                    "default": "VALIDATION_ERROR",
                    "pattern": "^[A-Z0-9_]{1,64}$"
                  },
                  {
                    "name": "errorMessage",
                    "kind": "optional",
                    "type": "string",
                    "nullable": true,
                    "description": "<p>Detailed description of the error, which may include information from the request.</p>",
                    "example": "One or more validation failures have occurred",
                    "default": "One or more validation failures have occurred",
                    "pattern": "^.+$"
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/ErrorResponse",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://sand-api.monoova.com/au/security/oauth-v1/Token \\\n     --header 'accept: application/json'"
        },
        {
          "id": "example-1-javascript",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://sand-api.monoova.com/au/security/oauth-v1/Token\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "example-2-ruby",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://sand-api.monoova.com/au/security/oauth-v1/Token\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://sand-api.monoova.com/au/security/oauth-v1/Token\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "example-0-curl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// OK. Returns the bearer token.\n{\n  \"token\": \"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjEwMDQ4MDAsImV4cCI6MTc2MTAwODQwMH0.x1gXndPwqQy7R5IPDu2aND26vkx3SZ0GU_LS-VOg7RA\"\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Bad Request. The request is invalid. Check errors for details.\n{\n  \"traceId\": \"4ea61012-2d9b-413d-a5b4-90ad69a68741\",\n  \"errors\": [\n    {\n      \"errorCode\": \"VALIDATION_ERROR\",\n      \"errorMessage\": \"One or more validation failures have occurred\"\n    }\n  ]\n}"
        },
        {
          "id": "response-2-401",
          "language": "401",
          "code": "// Unauthorized. Authentication failed because the mAccount number or API key is missing or incorrect. After 10 failed authentication attempts, your account is blocked and requests return 401 until you roll your API key in the Monoova portal.\n"
        },
        {
          "id": "response-3-500",
          "language": "500",
          "code": "// Internal Server Error. An unexpected error occurred. Try again later and contact Monoova support if the problem persists.\n{\n  \"traceId\": \"4ea61012-2d9b-413d-a5b4-90ad69a68741\",\n  \"errors\": [\n    {\n      \"errorCode\": \"VALIDATION_ERROR\",\n      \"errorMessage\": \"One or more validation failures have occurred\"\n    }\n  ]\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}