Create a service account
POST
/api/security/serviceAccounts
const url = 'https://example.com/api/security/serviceAccounts';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"example","description":"example","roles":["example"],"groups":["example"],"repos":[{"CACHE_ROOT":"my-repo","id":"repo-123","permission":"write"}]}'};
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://example.com/api/security/serviceAccounts \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "example", "description": "example", "roles": [ "example" ], "groups": [ "example" ], "repos": [ { "CACHE_ROOT": "my-repo", "id": "repo-123", "permission": "write" } ] }'Creates a new service account. The secret will be returned in the response.
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”Media typeapplication/json
object
name
Display name
string
description
Description
string
roles
Role assignments
Array<string>
groups
Group memberships
Array<string>
repos
Repository permissions
Array<object>
object
CACHE_ROOT
required
Repository namespace
string
Example
my-repoid
required
Repository ID
string
Example
repo-123permission
required
Permission level (view, write, admin)
string
Example
writeResponses
Section titled “Responses”Service account created successfully
Media typeapplication/json
object
id
required
Service account ID
string
secret
required
Service account secret — bcrypt hash in storage; the plaintext value is only returned once at creation time.
string
searchId
required
Searchable ID
string
name
required
Service account name
string
repos
Repository permissions
Array<object>
object
CACHE_ROOT
required
Repository namespace
string
id
required
Repository ID
string
permission
required
Permission level (view, write, admin)
string
roles
Assigned roles
Array<string>
groups
Group memberships
Array<string>
type
Entity type
string
description
Service account description
string
Example
{ "id": "api-service", "searchId": "api-service", "name": "API Service", "repos": [], "roles": [], "groups": [], "type": "serviceAccount", "description": ""}Invalid request