---
agentTools:
  projectIndex: https://docs.privakey.com/llms.txt
---

# Bind Account

Creates or associates an account from your system to a Privakey account.

**If the accountId has not yet been used**, a new account is created and its Privakey GUID ("privakeyId") is returned. The location URL of the new account is placed in the header. Additionally, a "sessionToken" is returned. Both the privakeyId and sessionToken must then be passed to the device the user is trying to register.

** If the accountId has already been used**, its Privakey GUID is simply returned.

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "API Settings",
    "version": "2.4"
  },
  "servers": [
    {
      "url": "https://cloud.privakey.com"
    }
  ],
  "security": [
    {}
  ],
  "paths": {
    "/api/account/bind": {
      "put": {
        "summary": "Bind Account",
        "description": "Creates or associates an account from your system to a Privakey account.\n\n**If the accountId has not yet been used**, a new account is created and its Privakey GUID (\"privakeyId\") is returned. The location URL of the new account is placed in the header. Additionally, a \"sessionToken\" is returned. Both the privakeyId and sessionToken must then be passed to the device the user is trying to register.\n\n** If the accountId has already been used**, its Privakey GUID is simply returned.",
        "operationId": "bind-account",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "description": "Either Basic or HMAC, depending on how the Request Origin is configured.",
            "required": true,
            "schema": {
              "type": "string",
              "default": "Basic <basic creds>"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId"
                ],
                "properties": {
                  "accountId": {
                    "type": "string",
                    "description": "The user's account id"
                  },
                  "userInfo": {
                    "type": "string",
                    "description": "Additional user info to be stored with this account. It will be returned with all GetAccount calls. PrivakeyCX does not use this, it is for convenience only."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "201",
            "content": {
              "application/json": {
                "examples": {
                  "Created": {
                    "value": "{\n    \"privakeyId\": \"37e0e8ef-cf1c-482d-88aa-ee7a63b250ca\",\n    \"appSpaceGuid\": \"354a27a1-7ed8-4652-90e4-6b5b630950ea\",\n    \"sessionToken\": \"c4f51044-3b4c-4d0b-9370-24a4400ae5d0\",\n    \"appSpaceName\": \"Service Name\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "privakeyId": {
                      "type": "string",
                      "example": "37e0e8ef-cf1c-482d-88aa-ee7a63b250ca"
                    },
                    "appSpaceGuid": {
                      "type": "string",
                      "example": "354a27a1-7ed8-4652-90e4-6b5b630950ea"
                    },
                    "sessionToken": {
                      "type": "string",
                      "example": "c4f51044-3b4c-4d0b-9370-24a4400ae5d0"
                    },
                    "appSpaceName": {
                      "type": "string",
                      "example": "Service Name"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        },
        "deprecated": false,
        "security": [],
        "x-readme": {
          "code-samples": [
            {
              "language": "curl",
              "code": "curl --location --request PUT \"https://cloud.privakey.com/api/account/bind\" --header \"Authorization: Basic <basic creds>\" --header \"Content-Type: application/x-www-form-urlencoded\" --data \"accountId=999999\""
            },
            {
              "language": "javascript",
              "code": "const body = { accountId: 999999 }\nconst options = {\n  headers: {'Authorization':`Basic ${basicCreds}`},\n  method: 'PUT',\n  body\n}\n\nfetch('https://cloud.privakey.com/api/account/bind', options)\n  .then(data => console.log(data.sessionToken.guid))"
            }
          ],
          "samples-languages": [
            "curl",
            "javascript"
          ]
        }
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": false,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "660d684fcb33080067214619:660d684fcb3308006721462e"
}
```