---
title: Create 2D viewer token
slug: viewer-2d/create-2d-viewer-token
docTags: 
createdAt: 2024-06-10T11:16:37.100Z
---

{
  "id": "-5d2MuYIaCjX6p5KUPaXs",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.catenda.com/v2/projects/{project-id}/viewer2d/token",
    "servers": [
      {
        "url": "https://api.catenda.com/v2/projects/{project-id}/viewer2d/token"
      }
    ],
    "name": "Create 2D viewer token",
    "description": "Get a 2D Viewer token to access viewer data.\n\nThe response will indicate which revisions the token is valid for.\n\nDefault usage is to provide a revision id.\n",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "project-id",
          "type": "string",
          "example": "af2d8af0fa54465b89bf26dd3d92cfd0",
          "description": "Catenda project id"
        }
      ],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "schema": [
            {
              "name": "model",
              "kind": "optional",
              "type": "string",
              "description": "Limit by model id",
              "example": "5f61fc16dac34d4e8d450b35bce62cf4"
            },
            {
              "name": "revision",
              "kind": "optional",
              "type": "string",
              "description": "Limit by revision id",
              "example": "28376aec8d04342dac4bf89cc9735ar4"
            }
          ],
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "Bearer",
          "name": "Bearer",
          "kind": "optional",
          "type": "http",
          "scheme": "bearer"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "OK",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "Represents a time limited access token to grant access to viewer data, valid for one hour.",
            "customType": "viewer-2d-token",
            "schema": [
              {
                "name": "revisions",
                "kind": "optional",
                "type": "array",
                "description": "The set of revisions the token grants access to",
                "modelRef": "#/components/schemas/model-revision",
                "customType": "model-revision[]",
                "schema": [
                  {
                    "name": "comment",
                    "kind": "optional",
                    "type": "string",
                    "description": "Text describing the revision, limited to 64K characters",
                    "example": "Revision description"
                  },
                  {
                    "name": "createdAt",
                    "kind": "optional",
                    "type": "string",
                    "description": "The date and time the revision was created in ISO 8601 format",
                    "example": "2016-09-26T14:45:20.000Z"
                  },
                  {
                    "name": "id",
                    "kind": "optional",
                    "type": "string",
                    "description": "A unique identifier for the revision, represented as compacted UUID using 32 hexadecimal characters.",
                    "example": "924809076a694255c489d236517a55da"
                  },
                  {
                    "name": "model",
                    "kind": "optional",
                    "type": "object",
                    "description": "Represents an IFC model as a set of Revisions.\n\nA large building project can contain multiple IFC models.\n\nThey are often divided by domain (architecture, electrical, etc.)\n",
                    "modelRef": "#/components/schemas/model",
                    "customType": "model",
                    "schema": [
                      {
                        "name": "id",
                        "kind": "optional",
                        "type": "string",
                        "description": "A unique identifier for a model, represented as compacted UUID using 32 hexadecimal characters",
                        "example": "47024671cbd642a9c7c84808d4d509f5"
                      },
                      {
                        "name": "name",
                        "kind": "optional",
                        "type": "string",
                        "description": "The name of the model, limited to 512 characters",
                        "example": "Model description"
                      }
                    ]
                  },
                  {
                    "name": "user",
                    "kind": "optional",
                    "type": "object",
                    "description": "Represents a User, Organization or Team.\n\nA User is someone with a Catenda account, commonly representing a person.\n\nAn Organization represents a company, project organization or an application. Organizations do not have a username and cannot sign in to Catenda.\n\nA Team represents a group of users within a project. Teams do not have a username and cannot sign in to Catenda.\n",
                    "modelRef": "#/components/schemas/user",
                    "customType": "user",
                    "schema": [
                      {
                        "name": "id",
                        "kind": "optional",
                        "type": "string",
                        "description": "Represented as compacted UUID using 32 hexadecimal characters",
                        "example": "524809076a694255b989d236517a55da"
                      },
                      {
                        "name": "name",
                        "kind": "optional",
                        "type": "string",
                        "description": "The name of the user, limited to 128 characters",
                        "example": "John Doe"
                      },
                      {
                        "name": "username",
                        "kind": "optional",
                        "type": "string",
                        "description": "The handle the user identifies with. \n\nCommonly the username will be in email address format. Usernames are unique but subject to change, we recommend using the id field to reference users instead.\n\nIf the user represents an organization or a team the value is always null.\n\nLimited to 50 characters.\n",
                        "example": "john@doe.com"
                      },
                      {
                        "name": "email",
                        "kind": "optional",
                        "type": "string",
                        "description": "Email address of the User",
                        "example": "john@doe.com"
                      },
                      {
                        "name": "createdAt",
                        "kind": "optional",
                        "type": "string",
                        "description": "The date and time the user was created in ISO 8601 format",
                        "example": "2016-09-20T14:55:22.000Z"
                      },
                      {
                        "name": "avatarUrl",
                        "kind": "optional",
                        "type": "string",
                        "description": "The URL for the user avatar",
                        "example": "https://api.catenda.com/v2/avatar/397t0ccd8f74516096c738de15dc6512"
                      },
                      {
                        "name": "type",
                        "kind": "optional",
                        "type": "string",
                        "description": "The type of user, valid values are:\n  - user\n  - organization\n  - team\n",
                        "example": "user"
                      }
                    ]
                  },
                  {
                    "name": "version",
                    "kind": "optional",
                    "type": "integer",
                    "description": "A number that is incremented for each new revision of a model",
                    "example": 1
                  }
                ]
              },
              {
                "name": "token",
                "kind": "optional",
                "type": "string",
                "description": "The token value, valid for one hour.",
                "example": "ba16ee5e36054019917210c4559bcca0"
              },
              {
                "name": "url",
                "kind": "optional",
                "type": "string",
                "description": "URL used to load models within a viewer instance",
                "example": "https://api.catenda.com/v2/projects/67551168422040148d8ae198a321494d/viewer2d/geometry?token=ba16ee5e36054019917210c4559bcca0"
              }
            ],
            "modelRef": "#/components/schemas/viewer-2d-token",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "UJwAEyhgPBeNNexrKtb5q",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.catenda.com/v2/projects/{project-id}/viewer2d/token \\\n     --header 'accept: application/json'"
        },
        {
          "id": "6wP0FFnm1gHKLXy65ryUZ",
          "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://api.catenda.com/v2/projects/{project-id}/viewer2d/token\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "sANmsKfpcaANLaeuodc-z",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.catenda.com/v2/projects/{project-id}/viewer2d/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": "Pexgr2UFrPdO007lb8QhB",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.catenda.com/v2/projects/{project-id}/viewer2d/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": "UJwAEyhgPBeNNexrKtb5q"
    },
    "results": {
      "languages": [
        {
          "id": "CsWiReKcR18xaI2g2zG5w",
          "language": "200",
          "code": "// OK\n{\n  \"revisions\": [\n    {\n      \"comment\": \"Revision description\",\n      \"createdAt\": \"2016-09-26T14:45:20.000Z\",\n      \"id\": \"924809076a694255c489d236517a55da\",\n      \"model\": {\n        \"id\": \"47024671cbd642a9c7c84808d4d509f5\",\n        \"name\": \"Model description\"\n      },\n      \"user\": {\n        \"id\": \"524809076a694255b989d236517a55da\",\n        \"name\": \"John Doe\",\n        \"username\": \"john@doe.com\",\n        \"email\": \"john@doe.com\",\n        \"createdAt\": \"2016-09-20T14:55:22.000Z\",\n        \"avatarUrl\": \"https://api.catenda.com/v2/avatar/397t0ccd8f74516096c738de15dc6512\",\n        \"type\": \"user\"\n      },\n      \"version\": 1\n    }\n  ],\n  \"token\": \"ba16ee5e36054019917210c4559bcca0\",\n  \"url\": \"https://api.catenda.com/v2/projects/67551168422040148d8ae198a321494d/viewer2d/geometry?token=ba16ee5e36054019917210c4559bcca0\"\n}"
        }
      ],
      "selectedLanguageId": "CsWiReKcR18xaI2g2zG5w"
    }
  },
  "children": [
    {
      "id": "kA2TYsUrMWERc1A4Z1XLz",
      "type": "paragraph",
      "children": [
        {
          "text": "Get a 2D Viewer token to access viewer data."
        }
      ]
    },
    {
      "id": "R7l5zVNV9g4cDHQSYOH5d",
      "type": "paragraph",
      "children": [
        {
          "text": "The response will indicate which revisions the token is valid for."
        }
      ]
    },
    {
      "id": "xX97E522AJT6X2iOgGNYP",
      "type": "paragraph",
      "children": [
        {
          "text": "Default usage is to provide a revision id."
        }
      ]
    }
  ]
}