> ## Documentation Index
> Fetch the complete documentation index at: https://docs.akua.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Set an Organization policy

Replaces all bindings when `If-Match` is the current etag; removing a member removes their access. Only an owner adds or removes `roles/owner`, and the last owner stays (422). Requests in its Workspaces see the change within 30 seconds.

`POST https://api.akua.dev/v1/organizations/{id}:setIamPolicy`

## Authorizations

- `Authorization: Bearer <token>` (BearerAuth): Bearer token for the authenticated caller.

## Headers

- `idempotency-key` (string): Optional caller-supplied idempotency key. Any non-empty key up to 64 characters is accepted. Endpoint-specific documentation describes how the key is used. Required string length: `1 - 64`. Example: `"create-prod-2026-05-07"`.
- `if-match` (string, required): The `etag` of the resource version the client last read. Required on writes when the resource exposes an `etag` field. Mismatch returns 409 `ABORTED` with the current etag in the error metadata. Required string length: `1 - 256`. Example: `"42"`.

## Path Parameters

- `id` (string, required): Organization ID, `org_<id>`. Required string length: `3 - 54`.

## Body

Required.

`application/json`: `SetOrganizationIamPolicyRequest`

- `bindings` (object[], required): Maximum array length: `100 elements`.
  - `role` (string, required): A basic role `roles/<name>` or a predefined role `roles/<service>.<role>`. Pattern: `^roles\/(owner|admin|member|viewer|[a-z][a-z0-9-]{0,62}\.[a-z][A-Za-z]{0,62})$`. Example: `"roles/admin"`.
  - `members` (string[], required): Required array length: `1 - 64 elements`.
  - `condition` (object)
    - `title` (string, required): Required string length: `1 - 100`.
    - `description` (string): Maximum string length: `512`.
    - `expires_at` (integer): Unix timestamp (seconds). Required range: `0 <= x <= 9007199254740991`.
    - `operations` (string[]): Required array length: `1 - 100 elements`.

## Response

### 200: Policy

`application/json`: `Policy`

- `bindings` (object[], required): Maximum array length: `100 elements`.
  - `role` (string, required): A basic role `roles/<name>` or a predefined role `roles/<service>.<role>`. Pattern: `^roles\/(owner|admin|member|viewer|[a-z][a-z0-9-]{0,62}\.[a-z][A-Za-z]{0,62})$`. Example: `"roles/admin"`.
  - `members` (string[], required): Required array length: `1 - 64 elements`.
  - `condition` (object)
    - `title` (string, required): Required string length: `1 - 100`.
    - `description` (string): Maximum string length: `512`.
    - `expires_at` (integer): Unix timestamp (seconds). Required range: `0 <= x <= 9007199254740991`.
    - `operations` (string[]): Required array length: `1 - 100 elements`.
- `etag` (string, required): Pass as `If-Match` on `setIamPolicy`. OUTPUT_ONLY. Maximum string length: `64`.

### 400: The request is malformed.

`application/json`: `ApiBadRequest`

- `_tag` (enum<string>, required): Available options: `"Validation"`.
- `success` (enum<boolean>, required): Available options: `false`.
- `errors` (object[], required): Minimum array length: `1 element`.
  - `code` (integer, required): Machine-readable error code. Required range: `-9007199254740991 <= x <= 9007199254740991`. Example: `7002`.
  - `message` (string, required): Human-readable error message. Example: `"Resource not found"`.
  - `path` (string[]): Field path that caused the error, when applicable. Example: `["body","name"]`.
  - `metadata` (record<string, string>)
- `result` (object, required)

### 401: Missing, invalid or expired credential.

`application/json`: `ApiUnauthorized`

- `_tag` (enum<string>, required): Available options: `"Unauthorized"`.
- `success` (enum<boolean>, required): Available options: `false`.
- `errors` (object[], required): Minimum array length: `1 element`.
  - `code` (integer, required): Machine-readable error code. Required range: `-9007199254740991 <= x <= 9007199254740991`. Example: `7002`.
  - `message` (string, required): Human-readable error message. Example: `"Resource not found"`.
  - `path` (string[]): Field path that caused the error, when applicable. Example: `["body","name"]`.
  - `metadata` (record<string, string>)
- `result` (object, required)

### 403: The credential may not act in this workspace.

`application/json`: `ApiForbidden`

- `_tag` (enum<string>, required): Available options: `"Forbidden"`.
- `success` (enum<boolean>, required): Available options: `false`.
- `errors` (object[], required): Minimum array length: `1 element`.
  - `code` (integer, required): Machine-readable error code. Required range: `-9007199254740991 <= x <= 9007199254740991`. Example: `7002`.
  - `message` (string, required): Human-readable error message. Example: `"Resource not found"`.
  - `path` (string[]): Field path that caused the error, when applicable. Example: `["body","name"]`.
  - `metadata` (record<string, string>)
- `result` (object, required)

### 404: The resource was not found in this workspace.

`application/json`: `ApiNotFound`

- `_tag` (enum<string>, required): Available options: `"NotFound"`.
- `success` (enum<boolean>, required): Available options: `false`.
- `errors` (object[], required): Minimum array length: `1 element`.
  - `code` (integer, required): Machine-readable error code. Required range: `-9007199254740991 <= x <= 9007199254740991`. Example: `7002`.
  - `message` (string, required): Human-readable error message. Example: `"Resource not found"`.
  - `path` (string[]): Field path that caused the error, when applicable. Example: `["body","name"]`.
  - `metadata` (record<string, string>)
- `result` (object, required)

### 409: The resource changed since the etag the client sent; the current etag is in the metadata. | The idempotency key was already used for a different request.

`application/json`: `object`

- Any of:
  - `PreconditionFailed`
    - `_tag` (enum<string>, required): Available options: `"PreconditionFailed"`.
    - `success` (enum<boolean>, required): Available options: `false`.
    - `errors` (object[], required): Required array length: `1 - 1 element`.
      - `code` (enum<number>, required): Available options: `7006`.
      - `message` (string, required)
      - `metadata` (object, required)
        - `current_etag` (string, required)
        - `{key}` (string)
    - `result` (object, required)
  - `IdempotencyConflict`
    - `_tag` (enum<string>, required): Available options: `"IdempotencyConflict"`.
    - `success` (enum<boolean>, required): Available options: `false`.
    - `errors` (object[], required): Minimum array length: `1 element`.
      - `code` (integer, required): Machine-readable error code. Required range: `-9007199254740991 <= x <= 9007199254740991`. Example: `7002`.
      - `message` (string, required): Human-readable error message. Example: `"Resource not found"`.
      - `path` (string[]): Field path that caused the error, when applicable. Example: `["body","name"]`.
      - `metadata` (record<string, string>)
    - `result` (object, required)

### 422: The request is well-formed but cannot be processed.

`application/json`: `ApiUnprocessable`

- `_tag` (enum<string>, required): Available options: `"Unprocessable"`.
- `success` (enum<boolean>, required): Available options: `false`.
- `errors` (object[], required): Minimum array length: `1 element`.
  - `code` (integer, required): Machine-readable error code. Required range: `-9007199254740991 <= x <= 9007199254740991`. Example: `7002`.
  - `message` (string, required): Human-readable error message. Example: `"Resource not found"`.
  - `path` (string[]): Field path that caused the error, when applicable. Example: `["body","name"]`.
  - `metadata` (record<string, string>)
- `result` (object, required)

### 503: The service is temporarily unavailable.

`application/json`: `ApiServiceUnavailable`

- `_tag` (enum<string>, required): Available options: `"ServiceUnavailable"`.
- `success` (enum<boolean>, required): Available options: `false`.
- `errors` (object[], required): Minimum array length: `1 element`.
  - `code` (integer, required): Machine-readable error code. Required range: `-9007199254740991 <= x <= 9007199254740991`. Example: `7002`.
  - `message` (string, required): Human-readable error message. Example: `"Resource not found"`.
  - `path` (string[]): Field path that caused the error, when applicable. Example: `["body","name"]`.
  - `metadata` (record<string, string>)
- `result` (object, required)

## Example request

```bash
curl --request POST \
  --url 'https://api.akua.dev/v1/organizations/org_j572abc123def456:setIamPolicy' \
  --header 'Authorization: Bearer <token>' \
  --header 'if-match: 42' \
  --header 'Content-Type: application/json' \
  --data '{
    "bindings": [
      {
        "role": "roles/admin",
        "members": [
          "user:usr_j572abc"
        ],
        "condition": {
          "title": "<string>",
          "description": "<string>",
          "expires_at": 123,
          "operations": [
            "<string>"
          ]
        }
      }
    ]
  }'
```

## Example response

`200` `application/json`

```json
{
  "bindings": [
    {
      "role": "roles/admin",
      "members": [
        "user:usr_j572abc"
      ],
      "condition": {
        "title": "<string>",
        "description": "<string>",
        "expires_at": 123,
        "operations": [
          "<string>"
        ]
      }
    }
  ],
  "etag": "<string>"
}
```
