Skip to main content
POST
/
agents
/
{agentId}
/
device-codes
cURL
curl --request POST \
  --url https://api.lightspark.com/grid/2025-10-13/agents/{agentId}/device-codes \
  --header 'Authorization: Basic <encoded-value>'
import LightsparkGrid from '@lightsparkdev/grid';

const client = new LightsparkGrid({
username: process.env['GRID_CLIENT_ID'], // This is the default and can be omitted
password: process.env['GRID_CLIENT_SECRET'], // This is the default and can be omitted
});

const agentDeviceCode = await client.agents.deviceCodes.regenerate('agentId');

console.log(agentDeviceCode.agentId);
package com.lightspark.grid.example

import com.lightspark.grid.client.LightsparkGridClient
import com.lightspark.grid.client.okhttp.LightsparkGridOkHttpClient
import com.lightspark.grid.models.agents.AgentDeviceCode
import com.lightspark.grid.models.agents.devicecodes.DeviceCodeRegenerateParams

fun main() {
val client: LightsparkGridClient = LightsparkGridOkHttpClient.fromEnv()

val agentDeviceCode: AgentDeviceCode = client.agents().deviceCodes().regenerate("agentId")
}
{
  "code": "GRID-AGENT-X7K9-M2P4",
  "agentId": "Agent:019542f5-b3e7-1d02-0000-000000000001",
  "expiresAt": "2025-07-22T17:32:28Z",
  "redeemed": false
}
{
"status": 400,
"message": "<string>",
"details": {}
}
{
"status": 401,
"message": "<string>",
"details": {}
}
{
"status": 404,
"message": "<string>",
"details": {}
}
{
"status": 409,
"message": "<string>",
"details": {}
}
{
"status": 500,
"message": "<string>",
"details": {}
}

Authorizations

Authorization
string
header
required

API token authentication using format <api token id>:<api client secret>

Path Parameters

agentId
string
required

System-generated unique agent identifier

Response

New device code generated successfully

code
string
required

Human-readable device code used to install and connect the agent software.

Example:

"GRID-AGENT-X7K9-M2P4"

agentId
string
required

The agent this device code belongs to.

Example:

"Agent:019542f5-b3e7-1d02-0000-000000000001"

expiresAt
string<date-time>
required

Timestamp when this device code expires.

Example:

"2025-07-22T17:32:28Z"

redeemed
boolean
required

Whether this device code has already been redeemed by the agent.

Example:

false