Authentication
ANT supports two authentication methods: API keys for programmatic access and session cookies for the web dashboard.
API Key Authentication
For API requests, include your API key in the Authorization header:
Authorization: Bearer ant_xxxxxxxxxxxxxxxxAPI keys start with ant_ and are 40+ characters long.
Endpoints
POST
/auth/registerCreate a new account and workspace
Request Body
{
"email": "[email protected]",
"password": "your-password",
"workspaceName": "My Project" // optional
}Response
{
"user": {
"id": "usr_abc123",
"email": "[email protected]"
},
"workspace": {
"id": "wsp_xyz789",
"name": "My Project"
},
"apiKey": "ant_xxxxxxxxxxxxxxxx",
"token": "session_token_here"
}POST
/auth/loginLog in to an existing account
Request Body
{
"email": "[email protected]",
"password": "your-password"
}Response
{
"user": {
"id": "usr_abc123",
"email": "[email protected]"
},
"workspaces": [
{ "id": "wsp_xyz789", "name": "My Project" }
],
"token": "session_token_here"
}GET
/auth/meGet the current authenticated user
Requires session authentication (cookie).
Response
{
"user": {
"id": "usr_abc123",
"email": "[email protected]",
"createdAt": "2024-01-15T10:30:00Z"
},
"workspaces": [
{
"id": "wsp_xyz789",
"name": "My Project",
"creditsBalance": 10.50
}
]
}POST
/auth/logoutEnd the current session
Clears the session cookie. Returns { "success": true }.
Device Authorization Flow
For CLI tools and devices without browsers, use the device auth flow to obtain an API key.
POST
/auth/device/codeRequest a device code
Response
{
"device_code": "dev_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"user_code": "ABCD-1234",
"verification_uri": "https://antbase.ai/device",
"expires_in": 900
}Show user_code and verification_uri to the user.
POST
/auth/device/tokenPoll for authorization
Request Body
{
"device_code": "dev_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}Responses
Pending (keep polling):
{ "error": "authorization_pending" }Success:
{
"api_key": "ant_xxxxxxxxxxxxxxxx",
"workspace": { "id": "wsp_xyz789", "name": "My Project" }
}