Applications

Endpoint: /api/iam/applications/

An application is an identity for automation. Create one before issuing its service tokens. Each token’s scopes must fit the application’s global roles; grant the application a global role before creating the token.

Authentication and permissions

Use a signed-in session or a personal API token. Service tokens cannot call this API. A personal token needs the matching application:create, application:read, application:update or application:delete scope.

Every authenticated member can list and read applications. Creating one needs application:create; changing or deleting one needs application:update or application:delete on that application. Admins hold these permissions, and the creator receives the application:maintainer role on the application. Writes return 403 workspace_suspended while the workspace is suspended.

The examples use a personal API token for a caller with the required roles and scopes.

List applications

Request

http
GET /api/iam/applications/

Query parameters

ParameterTypeDescription
namestringFilter by name
service_typestringFilter by service type
searchstringSearch name and description
orderingstringname, service_type, added_at or updated_at; prefix with - for descending order. Default: name
pageintegerPage number, starting at 1
page_sizeintegerResults per page; default 15, maximum 100

Response

200 OK, using integer pagination. This example shows selected application fields:

json
{
  "count": 1,
  "current": 1,
  "next": null,
  "previous": null,
  "last": 1,
  "results": [
    {
      "id": "9d2e4b71-0c3a-4f5e-8b6d-1a2c3e4f5a6b",
      "name": "CI pipeline",
      "description": "Deployment checks",
      "service_type": "ci_cd",
      "permissions": {"update": true, "delete": true}
    }
  ]
}

Example

bash
curl "https://your-workspace.us1.alpacon.io/api/iam/applications/?service_type=ci_cd" \
  -H "Authorization: token=\"alpat-xxxxxxxxxxxxxxxxxx\""

Application fields

FieldTypeDescription
idUUIDRead-only application ID
namestringRequired; at most 128 characters, unique among applications that have not been deleted
descriptionstringDefault ""
service_typestringai_agent, ci_cd, monitoring, automation, integration or other; default other. Descriptive only
created_byobjectRead-only creator
usernamestring / nullCannot be set on create. On update, must be a valid Unix username not in use by another identity
shellstringAbsolute Linux path, at most 32 characters; default /usr/sbin/nologin. Applied only when a server account is created
home_directorystring / nullAbsolute path; null uses the OS default
provisioning_enabledbooleanDefault false; requires a username, so cannot be true on create
auto_provisioningbooleanDefault false; requires provisioning_enabled. Enabling it requests account provisioning across servers
uidinteger / nullAt least 1000; cannot conflict with a user or another application
added_at, updated_atdatetimeRead-only timestamps
permissionsobjectRead-only {update, delete} permission hints

For readers who are neither admins nor application owners, responses omit username, uid, shell, home_directory, provisioning_enabled and auto_provisioning. List responses omit shell and home_directory for everyone.

Create an application

Request

http
POST /api/iam/applications/

Send name and any optional fields from the table. Do not send username: it cannot be set at creation. Because provisioning requires a username, provisioning_enabled cannot be true in this request. Set the username and provisioning options afterward with PATCH.

Request body

json
{
  "name": "CI pipeline",
  "description": "Deployment checks",
  "service_type": "ci_cd"
}

Response

201 Created with the application fields. Creating an application beyond the workspace plan’s count limit returns 402 application_limit_exceeded, with axis: "application". The built-in alpacon application does not count toward that limit.

Example

bash
curl -X POST "https://your-workspace.us1.alpacon.io/api/iam/applications/" \
  -H "Authorization: token=\"alpat-xxxxxxxxxxxxxxxxxx\"" \
  -H "Content-Type: application/json" \
  -d '{"name":"CI pipeline","description":"Deployment checks","service_type":"ci_cd"}'

Get an application

http
GET /api/iam/applications/{id}/

id is the application UUID. Returns 200 with the application fields visible to you.

Update an application

Request

http
PATCH /api/iam/applications/{id}/
PUT /api/iam/applications/{id}/

Returns 200 with the updated application. id, created_by, timestamps and permissions are read-only.

Setting username binds matching server accounts that are not already linked to an identity. Changing it unbinds accounts automatically linked by the previous name. A name matching an existing server account or group can require approval: the request returns 400 approval_superuser_approve_required and creates an approval request.

Example

bash
curl -X PATCH "https://your-workspace.us1.alpacon.io/api/iam/applications/9d2e4b71-0c3a-4f5e-8b6d-1a2c3e4f5a6b/" \
  -H "Authorization: token=\"alpat-xxxxxxxxxxxxxxxxxx\"" \
  -H "Content-Type: application/json" \
  -d '{"username":"ci-deploy","provisioning_enabled":true}'

Bind or unbind server accounts

Request

http
POST /api/iam/applications/{id}/system-users/
POST /api/iam/applications/{id}/system-users/unassign/

A Superuser or the application’s maintainer can call these routes. If using a personal API token, it also needs application:update.

Both accept system_user_ids, a nonempty array of server-account UUIDs. Duplicate IDs are removed.

json
{
  "system_user_ids": ["7d3984de-49ab-4cc6-bcdf-21fbd35858b8"]
}

Response

Binding returns 200 with an array of accounts, each containing id, uid, username, server, server_name, login_enabled and is_pinned. A system account, an account bound to a user, or one bound to another application cannot be bound here.

Unbinding returns 200:

json
{
  "unassigned": 1,
  "system_user_ids": ["7d3984de-49ab-4cc6-bcdf-21fbd35858b8"]
}

Delete an application

http
DELETE /api/iam/applications/{id}/

Returns 204 No Content. The application’s service tokens stop authenticating immediately and disappear from the token list. Its roles are removed, provisioning is switched off and its server-account bindings are removed.

bash
curl -X DELETE "https://your-workspace.us1.alpacon.io/api/iam/applications/9d2e4b71-0c3a-4f5e-8b6d-1a2c3e4f5a6b/" \
  -H "Authorization: token=\"alpat-xxxxxxxxxxxxxxxxxx\""

Error responses

StatusError codeDescription
400uniqueName is already used by an application that has not been deleted
400application_username_invalidUsername supplied on create, or an invalid Unix username
400application_username_in_useUsername is already in use
400approval_superuser_approve_requiredA matching server account or group requires approval
400application_shell_invalid, application_home_directory_invalidInvalid shell or home-directory path
400application_uid_out_of_range, application_uid_in_useUID is below 1000 or conflicts with another identity
400application_provisioning_username_requiredProvisioning requested without a username
400application_auto_provisioning_requires_enabledAutomatic provisioning requested while provisioning is disabled
400application_system_user_not_foundA requested server account does not exist
400application_system_user_already_boundAccount is a system account or already bound to another identity
401auth_token_missingAuthentication missing or no accepted credential supplied
402application_limit_exceededWorkspace plan’s application count exceeded
403api_token_scope_missing, rbac_permission_required, rbac_object_permission_requiredMissing token scope or role permission
403workspace_suspendedWrites refused while the workspace is suspended
404api_not_foundApplication not found

See Error messages for the coded error format.

Last updated: