Create a new API token
POST
/api/v1/api_token
const url = 'https://app.prefactorai.com/api/v1/api_token';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"account_id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","agent_id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","environment_id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","expires_at":"2024-01-01T00:00:00Z","token_scope":"account"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://app.prefactorai.com/api/v1/api_token \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "account_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "agent_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "environment_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "expires_at": "2024-01-01T00:00:00Z", "token_scope": "account" }'Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”ApiToken_DetailsForCreate
object
account_id
One of:
Account_Id
A valid account ID
string
Example
013xrzp12g3nqk8ns6jadrqmpgrjkenyNull
Null
string
agent_id
environment_id
One of:
Environment_Id
A valid environment ID
string
Example
013xrzp12g3nqk8ns6jadrqmpgrjkenyNull
Null
string
expires_at
token_scope
Token scope
string
Example
accountResponses
Section titled “Responses”Success
Media typeapplication/json
object
details
ApiToken_Details
object
account_id
Account_Id
A valid account ID
string
agent_deployment_id
One of:
AgentDeployment_Id
A valid agent deployment ID
string
Null
Null
string
available_actions
ApiToken_AvailableActions
Available actions for this token based on its status
object
activate
Whether the token can be activated
boolean
delete
Whether the token can be deleted
boolean
revoke
Whether the token can be revoked
boolean
suspend
Whether the token can be suspended
boolean
created_by_admin_user_id
One of:
AdminUser_Id
A valid admin user ID
string
Null
Null
string
environment_id
One of:
Environment_Id
A valid environment ID
string
Null
Null
string
expires_at
When the token expires
string format: date-time
id
ApiToken_Id
A valid API token ID
string
inserted_at
When the token was created
string format: date-time
last_used_at
status
Current status of the token
string
token_scope
Scope of the token
string
type
Type of resource (always ‘api_token’)
string
updated_at
When the token was last updated
string format: date-time
status
string
token
The JWT token string (only available on creation)
string
Example
{ "details": { "account_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "agent_deployment_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "agent_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "created_by_admin_user_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "environment_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "expires_at": "2024-01-01T00:00:00Z", "id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "inserted_at": "2024-01-01T00:00:00Z", "last_used_at": "2024-01-01T00:00:00Z", "status": "active", "token_scope": "account", "type": "api_token", "updated_at": "2024-01-01T00:00:00Z" }, "status": "success", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."}default
Section titled “default”Error