# Static Tokens

Device static tokens

## Get static tokens

> Retrieve all static authentication tokens for devices\
> \
> Note: to generate the QR code, that is acceptable by the official Blynk mobile applications, use the following format: \`{token}+{orgId}\`.\
> \
> Required permissions, when user-scoped authentication is used: \`MANAGE\_STATIC\_TOKENS\`.<br>

```json
{"openapi":"3.0.3","info":{"title":"Blynk Platform API","version":"1.0.0"},"tags":[{"name":"Static Tokens","description":"Device static tokens"}],"servers":[{"url":"https://{server_address}","description":"Blynk Server","variables":{"server_address":{"default":"blynk.cloud","description":"Your Blynk server domain"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth2 Bearer token obtained from authentication endpoint"}},"schemas":{"StaticToken":{"type":"object","properties":{"token":{"type":"string","description":"Static authentication token, that should be used for device claiming"},"orgId":{"type":"integer","format":"int32","description":"Organization ID, that the token belongs to"},"productId":{"type":"integer","format":"int32","description":"Template ID, that the token belongs to"},"deviceToken":{"type":"string","description":"Device token, that should be used on the device for authentication."},"createdAt":{"type":"integer","format":"int64","description":"Token creation timestamp"},"status":{"type":"string","enum":["CLAIMED","UNCLAIMED"],"description":"Static token status"},"ownerId":{"type":"integer","format":"int64","description":"User ID of the claimed device owner"},"deviceId":{"type":"integer","format":"int32","description":"Device ID of the claimed device"},"claimedOrgId":{"type":"integer","format":"int32","description":"Organization ID, that the device was claimed to"}},"required":["token","orgId","productId","deviceToken","createdAt","status"]},"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Error message"}},"required":["message"]}},"required":["error"]}}},"paths":{"/api/v1/organization/static-tokens":{"get":{"tags":["Static Tokens"],"summary":"Get static tokens","description":"Retrieve all static authentication tokens for devices\n\nNote: to generate the QR code, that is acceptable by the official Blynk mobile applications, use the following format: `{token}+{orgId}`.\n\nRequired permissions, when user-scoped authentication is used: `MANAGE_STATIC_TOKENS`.\n","operationId":"getStaticTokens","parameters":[{"name":"orgId","in":"query","schema":{"type":"integer","format":"int32"},"description":"Organization ID (optional). If not provided, the organization, that is associated with the authentication token, will be used."},{"name":"page","in":"query","schema":{"type":"integer","format":"int32","default":0,"minimum":0},"description":"Page number (0-indexed)"},{"name":"size","in":"query","schema":{"type":"integer","format":"int32","default":50,"minimum":1,"maximum":1000},"description":"Page size (max 1000)"}],"responses":{"200":{"description":"List of static tokens","content":{"application/json":{"schema":{"type":"object","properties":{"content":{"type":"array","items":{"$ref":"#/components/schemas/StaticToken"}},"totalElements":{"type":"integer","format":"int64","description":"Total number of static tokens in the organization"}},"required":["content","totalElements"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden"},"404":{"description":"Organization not found or access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too many requests"},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## Claim device by static token

> Claim a device using its static token (QR code). This endpoint creates a new device or transfers an existing device to the specified user's organization.\
> \
> The QR code can be in two formats:\
> \- Plain token: \`sqr\_gCCsLSydh3d0ArmZj50l9zr79JXVooBR\`\
> \- QR format with organization ID: \`sqr\_gCCsLSydh3d0ArmZj50l9zr79JXVooBR+1\`\
> \
> If the device doesn't exist, it will be created in the user's organization. If it exists in a different organization, it will be transferred to the user's organization (requires proper access permissions).\
> \
> \*\*Important\*\*: \
> \- The static token should not be already claimed\
> \- The OAuth client must have access to both the user specified in \`userId\` and the organization where the static token was created\
> \
> Required permissions, when user-scoped authentication is used: \`ORG\_DEVICES\_CREATE\`.\
> Required device view permission: \`OWN\_DEVICES\_VIEW\` or \`ORG\_DEVICES\_VIEW\`.\
> User-scoped tokens that set \`userId\` different from authenticated user ID also require \`ORG\_VIEW\_USERS\`.<br>

```json
{"openapi":"3.0.3","info":{"title":"Blynk Platform API","version":"1.0.0"},"tags":[{"name":"Static Tokens","description":"Device static tokens"}],"servers":[{"url":"https://{server_address}","description":"Blynk Server","variables":{"server_address":{"default":"blynk.cloud","description":"Your Blynk server domain"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth2 Bearer token obtained from authentication endpoint"}},"schemas":{"Device":{"type":"object","properties":{"id":{"type":"integer","format":"int32","description":"Device ID"},"name":{"type":"string","description":"Device name"},"templateId":{"type":"integer","format":"int32","description":"Template ID this device belongs to"},"originalTemplateId":{"type":"integer","format":"int32","description":"Original template ID from the template hierarchy (the root template ID this device is ultimately derived from)"},"orgId":{"type":"integer","format":"int32","description":"Organization ID this device belongs to"},"token":{"type":"string","description":"Device authentication token"},"activatedAt":{"type":"integer","format":"int64","description":"Device activation timestamp"},"ownerUserId":{"type":"integer","format":"int64","description":"Device owner identifier"},"hardwareInfo":{"$ref":"#/components/schemas/DeviceHardwareInfo"}},"required":["id","name","templateId","originalTemplateId","orgId","token"]},"DeviceHardwareInfo":{"type":"object","properties":{"version":{"type":"string","description":"Device firmware version"},"fwType":{"type":"string","description":"Device firmware type"},"blynkVersion":{"type":"string","description":"Version of the Blynk Library, that is used on the device"},"boardType":{"$ref":"#/components/schemas/BoardType"},"build":{"type":"string","description":"Firmware build number, that is used on the device"},"templateId":{"type":"string","description":"The identifier of the template that the device belongs to."}}},"BoardType":{"type":"string","enum":["Arduino","BBC_Microbit","ESP32","ESP8266","Lantronix_Fox_3","Microduino","Onion_Omega","Particle","Pycom_WiPy","Raspberry_Pi","Seeed_Wio_Terminal","SparkFun_Blynk_Board","Teensy","TinyDuino","NodeRed","Python","TI_CC3220","Iridium","Iridium_9704_Launch_Pad","NCD","Milesight","Seeed","Blues","MOKOSmart","Thermokon","Miromiko","Pepperl_Fuchs","Atim","Other"],"description":"Device board type"},"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Error message"}},"required":["message"]}},"required":["error"]}}},"paths":{"/api/v1/organization/static-tokens/claim":{"post":{"tags":["Static Tokens"],"summary":"Claim device by static token","description":"Claim a device using its static token (QR code). This endpoint creates a new device or transfers an existing device to the specified user's organization.\n\nThe QR code can be in two formats:\n- Plain token: `sqr_gCCsLSydh3d0ArmZj50l9zr79JXVooBR`\n- QR format with organization ID: `sqr_gCCsLSydh3d0ArmZj50l9zr79JXVooBR+1`\n\nIf the device doesn't exist, it will be created in the user's organization. If it exists in a different organization, it will be transferred to the user's organization (requires proper access permissions).\n\n**Important**: \n- The static token should not be already claimed\n- The OAuth client must have access to both the user specified in `userId` and the organization where the static token was created\n\nRequired permissions, when user-scoped authentication is used: `ORG_DEVICES_CREATE`.\nRequired device view permission: `OWN_DEVICES_VIEW` or `ORG_DEVICES_VIEW`.\nUser-scoped tokens that set `userId` different from authenticated user ID also require `ORG_VIEW_USERS`.\n","operationId":"claimStaticToken","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"qrCode":{"type":"string","description":"Static token QR code value (plain token or token+orgId format)","maxLength":200},"deviceName":{"type":"string","description":"Device name (optional). If not provided or empty, defaults to \"New Device\". Only letters, digits, spaces, apostrophes, underscores, and hyphens are allowed.","maxLength":50,"pattern":"^[a-zA-Z0-9 '\\-_]+$"},"userId":{"type":"integer","format":"int64","description":"User ID who will own the claimed device"}},"required":["qrCode","userId"]}}}},"responses":{"200":{"description":"Device claimed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Device"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden"},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too many requests"},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## Unclaim static tokens

> Remove device associations from static tokens. The static token itself won't be deleted.\
> \
> Returns 400 if no valid tokens were found to unclaim (tokens may be invalid, already unclaimed, or do not exist).\
> \
> Required permissions, when user-scoped authentication is used: \`MANAGE\_STATIC\_TOKENS\`, \`ORG\_DEVICES\_DELETE\`.<br>

```json
{"openapi":"3.0.3","info":{"title":"Blynk Platform API","version":"1.0.0"},"tags":[{"name":"Static Tokens","description":"Device static tokens"}],"servers":[{"url":"https://{server_address}","description":"Blynk Server","variables":{"server_address":{"default":"blynk.cloud","description":"Your Blynk server domain"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth2 Bearer token obtained from authentication endpoint"}},"schemas":{"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Error message"}},"required":["message"]}},"required":["error"]}}},"paths":{"/api/v1/organization/static-tokens/unclaim":{"post":{"tags":["Static Tokens"],"summary":"Unclaim static tokens","description":"Remove device associations from static tokens. The static token itself won't be deleted.\n\nReturns 400 if no valid tokens were found to unclaim (tokens may be invalid, already unclaimed, or do not exist).\n\nRequired permissions, when user-scoped authentication is used: `MANAGE_STATIC_TOKENS`, `ORG_DEVICES_DELETE`.\n","operationId":"unclaimStaticTokens","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"qrCodes":{"type":"array","items":{"type":"string","description":"Static token QR code value","maxLength":200},"description":"List of QR code tokens to unclaim","minItems":1,"maxItems":10000}},"required":["qrCodes"]}}}},"responses":{"204":{"description":"Tokens unclaimed successfully"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden or no access to the token's organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too many requests"},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.blynk.io/en/blynk.cloud/platform-https-api/static-tokens.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
