---
title: Create a session
slug: reference/create-a-session
docTags: 
createdAt: 2024-09-30T17:03:00.666Z
---

{
  "id": "glAHR63LqjP0K849qi4NL",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/session",
    "servers": [
      {
        "url": "https://app.amberflo.io/session"
      }
    ],
    "name": "Create a session",
    "description": "Obtain a session token and redirect url for the Customer Portal.\n",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "session-request",
          "schema": [
            {
              "name": "customerId",
              "kind": "required",
              "type": "string",
              "description": "Customer ID as defined in the [Customer API](ref:post_customers).",
              "example": "",
              "default": "24ad0b40-a217-11eb-b01a-19ff91d9370d"
            },
            {
              "name": "expirationEpochMilliSeconds",
              "kind": "optional",
              "type": "integer",
              "description": "Expiration date time represented as milliseconds since the Unix Epoch (1970-01-01T00:00:00Z) and using UTC. Default expiration is set for 24 hours.",
              "example": 0,
              "default": 1677695316
            },
            {
              "name": "returnUrl",
              "kind": "optional",
              "type": "string",
              "description": "The URL to return to in the Account application once done in the customer portal.",
              "example": "",
              "default": "https://starkindustries.com/"
            }
          ],
          "modelRef": "#/components/schemas/session-request",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "api_key",
          "name": "x-api-key",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful response",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "session-response",
            "schema": [
              {
                "name": "url",
                "kind": "optional",
                "type": "string",
                "example": "https://portal.amberflo.io/session/9cd47c746d194674c44184317e8f7f6483f2c47bbc24771ce96fcb594bce7fc5625d4f5f5c99?returnUrl=https%3A%2F%2Fnetlify.com%2F"
              },
              {
                "name": "sessionToken",
                "kind": "optional",
                "type": "string",
                "example": "9cd42972321b1123924184317f8d246483f2c47bbc27261eba6f9c5f1dce7e9a635a1d5d545"
              }
            ],
            "modelRef": "#/components/schemas/session-response",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "BSE7Pao1umEsXPrnOl_Uq",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/session \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"customerId\": \"24ad0b40-a217-11eb-b01a-19ff91d9370d\",\n     \"expirationEpochMilliSeconds\": 1677695316,\n     \"returnUrl\": \"https://starkindustries.com/\"\n     }'"
        },
        {
          "id": "goLDhR1QKon9rOvhGqG5e",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"customerId\": \"24ad0b40-a217-11eb-b01a-19ff91d9370d\",\n   \"expirationEpochMilliSeconds\": 1677695316,\n   \"returnUrl\": \"https://starkindustries.com/\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/session\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "t2rS-V13GcmJ70r3es8Ow",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/session\")\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\"\nrequest.body = JSON.dump({\n   \"customerId\": \"24ad0b40-a217-11eb-b01a-19ff91d9370d\",\n   \"expirationEpochMilliSeconds\": 1677695316,\n   \"returnUrl\": \"https://starkindustries.com/\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "KSaLmjaJsxif7uvNBSoA2",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/session\"\n\npayload = json.dumps({\n   \"customerId\": \"24ad0b40-a217-11eb-b01a-19ff91d9370d\",\n   \"expirationEpochMilliSeconds\": 1677695316,\n   \"returnUrl\": \"https://starkindustries.com/\"\n})\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": "BSE7Pao1umEsXPrnOl_Uq"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successful response\n{\n  \"url\": \"https://portal.amberflo.io/session/9cd47c746d194674c44184317e8f7f6483f2c47bbc24771ce96fcb594bce7fc5625d4f5f5c99?returnUrl=https%3A%2F%2Fnetlify.com%2F\",\n  \"sessionToken\": \"9cd42972321b1123924184317f8d246483f2c47bbc27261eba6f9c5f1dce7e9a635a1d5d545\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "id": "3nCZVjYpFeyo6mlY0ZD2s",
      "type": "paragraph",
      "children": [
        {
          "text": "Obtain a session token and redirect url for the Customer Portal.",
          "id": "OjzOQKQv-ZZOhwTR4OiGr"
        }
      ]
    }
  ]
}