Organization and Service Accounts: Identify the Organization, Create a Service Account, Issue and Revoke Its Credentials
Everything above a project lives in the organization: the Service Accounts that call the Config API and run Terraform, and their credentials. This example covers that layer end to end with the Config API:
1. Read the organization the calling Service Account belongs to (GET /configs/v1/organizations/current).
2. Create a Service Account with a role: all_editor may change configuration, all_viewer may only read.
3. Issue a credential for it; the private key comes back once, in service_account_config.
4. List and read credentials: metadata only, never the key again.
5. Update the account's display_name or description with the ETag it was read with.
6. Revoke a credential, then delete the account.
Every call carries a Service Account Bearer token; an Application Agent credential (X-IK-ClientKey) is refused.
Use case
Scenario: a CI pipeline needs its own identity to apply the organization's Terraform modules, separate from the people's accounts, and the security team wants credentials rotated and revocable without touching the Hub.
- An administrator's Service Account creates the pipeline's account and its first credential and hands the credential file to the pipeline's secret store.
- Rotation: issue a second credential, switch the pipeline, then delete the first. A deleted credential's token is refused at once with 401; the account's other credentials keep working.
- A read-only auditor gets the same account shape with role all_viewer.
The same resources exist in Terraform: see the Service account example in Terraform Configurations.
Requirements
Prerequisites:
- ServiceAccount credentials with the all_editor role, as a Bearer token in the Authorization header. An all_viewer account can read and list but gets 403 on create, update and delete.
- The organization's region: https://eu.api.indykite.com or https://us.api.indykite.com.
Required API access:
- GET /configs/v1/organizations/current
- POST, GET, PUT, DELETE /configs/v1/service-accounts
- POST, GET, DELETE /configs/v1/service-account-credentials
Steps
Step 1: Read the current organization
- GET /configs/v1/organizations/current, no parameters.
- Result: the organization's id, name, display_name, description and audit fields, with an etag header. The id is the organization_id every other call needs.
Step 2: Create a Service Account
- POST /configs/v1/service-accounts with organization_id, name, role, and optionally display_name and description.
- name is immutable: 2 to 63 characters, lowercase letters, digits and hyphens, starting with a letter and ending with a letter or digit, unique in the organization.
- role is all_editor or all_viewer; it cannot be changed later.
- Result: 201 with the account's id and an etag header. Read it back by id or by name: the response carries name, display_name, description and organization_id, not the role.
Step 3: Issue a credential
- POST /configs/v1/service-account-credentials with service_account_id, and optionally display_name (2 to 254 characters) and expire_time (RFC 3339, in the future).
- Result: 201 with id, kid, expire_time and the credentials file in service_account_config. With an expire_time the file carries a ready-to-use token; without one the credential never expires and the file carries only the private key, with which you sign your own JWT (Credentials guide).
- Keep service_account_config: the private key is not returned again.
Step 4: List and read credentials
- GET /configs/v1/service-account-credentials?organization_id=<gid>, optionally &search=<text> on name, display name or description; GET /configs/v1/service-account-credentials/{id} for one.
- Result: metadata only: id, kid, display_name, service_account_id, organization_id, expire_time, create_time, created_by.
Step 5: Update the account
- PUT /configs/v1/service-accounts/{id} with display_name and/or description; a field left null is unchanged, an empty string clears it, an empty body is refused with 422 "nothing to change".
- Send the current etag as If-Match to refuse a write over a concurrent change: a stale value gets 412 Precondition Failed. If-Match is optional.
- Result: 200 with the audit fields and a new etag.
Step 6: Revoke and delete
- DELETE /configs/v1/service-account-credentials/{id}: the credential's token is refused from then on; other credentials of the account are untouched.
- DELETE /configs/v1/service-accounts/{id}, optionally with If-Match, once nothing uses the account. Both return the deleted id.
These organization-level calls produce indykite.audit.config.* events (creating an account also records the role grant as indykite.audit.config.permission.assign), but such events belong to no project: they are neither delivered to an Event Sink nor chained in a project's tamper-proof trail.
Step 1
export API_URL=https://eu.api.indykite.com # or https://us.api.indykite.com, the region of your organization
export SA_TOKEN="<token from the credentials file of an existing all_editor Service Account>"Step 1
Read the organization of the calling Service Account. No parameters; the id in the response is the organization_id for every call below.
curl -sS "$API_URL/configs/v1/organizations/current" \
-H "Authorization: Bearer $SA_TOKEN" -D - -o organization.json
export ORG_ID=$(jq -r .id organization.json) # the organization GID, needed by every call belowThe 200 response, with an etag header alongside it.
{
"id": "gid:YOUR_ORGANIZATION_GID",
"name": "your-organization-name",
"display_name": "Your organization",
"description": "",
"create_time": "2025-03-04T10:12:33Z",
"created_by": "gid:YOUR_SERVICE_ACCOUNT_GID",
"update_time": "2025-03-04T10:12:33Z",
"updated_by": "gid:YOUR_SERVICE_ACCOUNT_GID"
}Step 2
Create the Service Account. name is immutable and must be unique in the organization; role is all_editor or all_viewer and cannot be changed afterwards. A duplicate name is refused with 409, a bad name or role with 422 and the exact rule in errors[].
{
"organization_id": "gid:YOUR_ORGANIZATION_GID",
"name": "terraform-ci",
"display_name": "CI pipeline",
"description": "Applies this organization's Terraform modules",
"role": "all_editor"
}The 201 response: the new account's id and audit fields, plus the etag header.
HTTP/2 201
etag: 2v3tVyPcKq4
{
"id": "gid:YOUR_SERVICE_ACCOUNT_GID",
"create_time": "2026-10-12T14:02:11Z",
"created_by": "gid:YOUR_ADMIN_SERVICE_ACCOUNT_GID",
"update_time": "2026-10-12T14:02:11Z",
"updated_by": "gid:YOUR_ADMIN_SERVICE_ACCOUNT_GID"
}Step 2
Read the account back, by GID or by name. The response carries the fields you set except the role; ?version=<n> reads an earlier version.
# by GID, or by name within the calling account's organization
curl -sS "$API_URL/configs/v1/service-accounts/terraform-ci" \
-H "Authorization: Bearer $SA_TOKEN" -D - | sed -n '/^etag/p;/^{/,$p'
{
"id": "gid:YOUR_SERVICE_ACCOUNT_GID",
"name": "terraform-ci",
"display_name": "CI pipeline",
"description": "Applies this organization's Terraform modules",
"organization_id": "gid:YOUR_ORGANIZATION_GID",
"create_time": "2026-10-12T14:02:11Z",
"created_by": "gid:YOUR_ADMIN_SERVICE_ACCOUNT_GID",
"update_time": "2026-10-12T14:02:11Z",
"updated_by": "gid:YOUR_ADMIN_SERVICE_ACCOUNT_GID"
}Step 3
Issue a credential. expire_time is optional: set within two years it yields a ready-to-use token in the file; farther ahead, or omitted (the credential then never expires), the file carries only the private key. A past date or a malformed one is refused with 422.
{
"service_account_id": "gid:YOUR_SERVICE_ACCOUNT_GID",
"display_name": "CI pipeline credential",
"expire_time": "2027-10-01T00:00:00Z"
}The 201 response. service_account_config is the credentials file, the only time the private key is returned; kid names the public key the platform keeps.
HTTP/2 201
{
"id": "gid:YOUR_SERVICE_ACCOUNT_CREDENTIAL_GID",
"kid": "…",
"display_name": "CI pipeline credential",
"service_account_id": "gid:YOUR_SERVICE_ACCOUNT_GID",
"expire_time": "2027-10-01T00:00:00Z",
"create_time": "2026-10-12T14:05:40Z",
"created_by": "gid:YOUR_ADMIN_SERVICE_ACCOUNT_GID",
"service_account_config": {
"serviceAccountId": "gid:YOUR_SERVICE_ACCOUNT_GID",
"endpoint": "eu.api.indykite.com",
"token": "eyJhbGciOiJFUzI1NiIsImtpZCI6Iu2026…",
"privateKeyJWK": {
"kty": "EC",
"crv": "P-256",
"alg": "ES256",
"use": "sig",
"kid": "…",
"x": "…",
"y": "…",
"d": "…"
},
"privateKeyPKCS8": "<the same key as PEM, PKCS #8>",
"privateKeyPKCS8Base64": "<the PEM, Base64-encoded>"
}
}Step 3
Keep the file straight from the response into the pipeline's secret store (here a local file for illustration).
# keep only the file your pipeline needs; the private key is never returned again
curl -sS -X POST "$API_URL/configs/v1/service-account-credentials" \
-H "Authorization: Bearer $SA_TOKEN" -H "Content-Type: application/json" \
--data @credential-create.json | jq .service_account_config > terraform-ci-credentials.json
chmod 600 terraform-ci-credentials.jsonStep 4
List the organization's credentials, optionally narrowed with search. Metadata only.
curl -sS "$API_URL/configs/v1/service-account-credentials?organization_id=$ORG_ID&search=CI" \
-H "Authorization: Bearer $SA_TOKEN"
{
"data": [
{
"id": "gid:YOUR_SERVICE_ACCOUNT_CREDENTIAL_GID",
"kid": "…",
"display_name": "CI pipeline credential",
"organization_id": "gid:YOUR_ORGANIZATION_GID",
"service_account_id": "gid:YOUR_SERVICE_ACCOUNT_GID",
"expire_time": "2027-10-01T00:00:00Z",
"create_time": "2026-10-12T14:05:40Z",
"created_by": "gid:YOUR_ADMIN_SERVICE_ACCOUNT_GID"
}
]
}Step 5
Update display_name and clear description, guarded by the etag read just before. A stale If-Match is refused with 412; a body with nothing to change with 422.
# read first to get the current etag, then send it back as If-Match
ETAG=$(curl -sS "$API_URL/configs/v1/service-accounts/gid:YOUR_SERVICE_ACCOUNT_GID" \
-H "Authorization: Bearer $SA_TOKEN" -D - -o /dev/null | awk 'tolower($1)=="etag:" {print $2}' | tr -d '\r')
curl -sS -X PUT "$API_URL/configs/v1/service-accounts/gid:YOUR_SERVICE_ACCOUNT_GID" \
-H "Authorization: Bearer $SA_TOKEN" -H "Content-Type: application/json" -H "If-Match: $ETAG" \
--data '{"display_name": "CI pipeline (eu)", "description": ""}'
{
"id": "gid:YOUR_SERVICE_ACCOUNT_GID",
"create_time": "2026-10-12T14:02:11Z",
"created_by": "gid:YOUR_ADMIN_SERVICE_ACCOUNT_GID",
"update_time": "2026-10-12T15:20:07Z",
"updated_by": "gid:YOUR_ADMIN_SERVICE_ACCOUNT_GID"
}Step 6
Revoke one credential, then delete the account once nothing depends on it. Both return the deleted id; a revoked credential's token gets 401 immediately.
# revoke one credential; the account's other credentials keep working
curl -sS -X DELETE "$API_URL/configs/v1/service-account-credentials/gid:YOUR_SERVICE_ACCOUNT_CREDENTIAL_GID" \
-H "Authorization: Bearer $SA_TOKEN"
# {"id": "gid:YOUR_SERVICE_ACCOUNT_CREDENTIAL_GID"}
# remove the account itself once nothing uses it (If-Match is optional here too)
curl -sS -X DELETE "$API_URL/configs/v1/service-accounts/gid:YOUR_SERVICE_ACCOUNT_GID" \
-H "Authorization: Bearer $SA_TOKEN"
# {"id": "gid:YOUR_SERVICE_ACCOUNT_GID"}API Endpoints
/configs/v1/organizations/current/configs/v1/service-accounts/configs/v1/service-accounts/{id}/configs/v1/service-account-credentials/configs/v1/service-account-credentials/{id}