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

# Authentication

> How to authenticate with the Compliance API

Every request to the Compliance API requires the following credentials:

* [Workspace ID](#workspace-id)
* [Workspace API key](#workspace-api-key)
* [Signed authentication token](#sign-an-authentication-token)

Together they show which workspace you may read and who is calling.

To connect, you [register once with Base44](https://docs.base44.com/developers/references/compliance-api/get-started/register-as-a-partner.md), get credentials from a workspace owner or admin, and sign an authentication token for each request.

> [!NOTE]
>
> The Compliance API is available for **Enterprise** workspaces only.

## Credentials

### Sign an authentication token

A signed authentication token is a [JSON Web Token (JWT)](https://jwt.io/introduction) that identifies you as the security partner. You sign each token with your signing key, which is the private key of the key pair you generated when you [registered with Base44](https://docs.base44.com/developers/references/compliance-api/get-started/register-as-a-partner.md). Send it in the `Authorization` header as a bearer token. Base44 verifies the signature with the public key you registered.

**To sign an authentication token:**

1. Create a token with the claims in the following table.

A claim is a field in the token. Include the following claims.

| Claim | Required | Description |
| - | - | - |
| `alg` (header) | Yes | The signing algorithm. Must be `RS256` or `ES256`. |
| `kid` (header) | No | The key ID. Set it if you registered more than 1 public key. |
| `iss` | Yes | The issuer, which is your `client_id` received at registration. |
| `aud` | Yes | Always `https://base44.com/api/v1/compliance`. |
| `iat` | Yes | Issue time, in seconds, not milliseconds. |
| `exp` | Yes | Expiration time, no more than 5 minutes after `iat`. |
| `jti` | Yes | A unique ID for the token. Base44 accepts each ID once. |

2. Use a JWT library to generate the token from the claims and your signing key. The result is the signed authentication token. Send it in the `Authorization` header as a bearer token when you [call a method](#send-a-request).

> [!NOTE]
>
> Sign a fresh token for every request, including every retry.

The following examples create the same token in each language, using a JWT library and an ES256 key. For an RSA key, sign with `RS256` instead. If you registered more than 1 key, also set `kid` in the token header to your key ID.

```python Python theme={null}
import uuid, datetime, jwt

def mint_token(private_pem, client_id):
    now = datetime.datetime.now(datetime.timezone.utc)
    return jwt.encode(
        {
            "iss": client_id,
            "aud": "https://base44.com/api/v1/compliance",
            "iat": int(now.timestamp()),
            "exp": int((now + datetime.timedelta(minutes=2)).timestamp()),
            "jti": str(uuid.uuid4()),
        },
        private_pem,
        algorithm="ES256",
    )
```

```js Node.js theme={null}
import crypto from "node:crypto";
import jwt from "jsonwebtoken";

export function mintToken(privatePem, clientId) {
  const now = Math.floor(Date.now() / 1000);
  return jwt.sign(
    {
      iss: clientId,
      aud: "https://base44.com/api/v1/compliance",
      iat: now,
      exp: now + 120,
      jti: crypto.randomUUID(),
    },
    privatePem,
    { algorithm: "ES256" },
  );
}
```

```go Go theme={null}
import (
	"time"

	"github.com/golang-jwt/jwt/v5"
	"github.com/google/uuid"
)

// privateKey is an *ecdsa.PrivateKey. For an RSA key, pass an *rsa.PrivateKey
// and use jwt.SigningMethodRS256.
func mintToken(privateKey any, clientID string) (string, error) {
	now := time.Now()
	claims := jwt.MapClaims{
		"iss": clientID,
		"aud": "https://base44.com/api/v1/compliance",
		"iat": now.Unix(),
		"exp": now.Add(2 * time.Minute).Unix(),
		"jti": uuid.NewString(),
	}
	return jwt.NewWithClaims(jwt.SigningMethodES256, claims).SignedString(privateKey)
}
```

### Workspace ID

The workspace ID identifies the workspace that a request reads. Use the workspace ID in the request path when you call a method. A workspace owner or admin finds it in the workspace settings and shares it with you.

**To get the workspace ID:**

1. Go to [app.base44.com](https://app.base44.com/).
2. Click the workspace name at the bottom left of the screen.
3. Click **Settings**.
4. Copy the workspace ID from the Settings URL, which has the form `https://app.base44.com/workspace/<workspace_id>/settings`.

### Workspace API key

A workspace owner or admin creates the key, chooses its [scopes](#scopes), and shares it with you, the security partner. The workspace API key authorizes access to exactly 1 workspace. Send the workspace API key in the `api_key` header when you call a method. Learn more about [Managing workspace secrets](https://docs.base44.com/Enterprise/workspace-secrets.md). For the steps from the workspace owner or admin's side, see [Connecting a security partner with the Compliance API](https://docs.base44.com/Enterprise/compliance-api.md).

**To create a workspace API key:**

1. Go to [app.base44.com](https://app.base44.com/).
2. Click the workspace name at the bottom left and click **Settings**.
3. Click **Secrets** in the sidebar.
4. Click **+ Create API Key**.
5. Enter a name for the key and an optional description.
6. Under **Permissions**, select the permissions the key should have. Each permission grants a [scope](#scopes).
7. Click **Create Key**.
8. Copy the key and store it somewhere safe.
9. Click **Done**.

#### Scopes

A scope specifies the data that a workspace API key can read. The workspace owner or admin chooses the scopes when they create the key.

In Base44, each scope appears as a permission. The following table lists the permission that grants each scope:

| Permission | Scope |
| - | - |
| Read compliance inventory | `compliance:inventory:read` |
| Read compliance member directory | `compliance:members:read` |
| Read compliance security findings | `compliance:findings:read` |

Learn more about [choosing permissions](https://docs.base44.com/Enterprise/compliance-api.md#choosing-permissions).

The following table lists the methods that each scope grants access to:

| Scope | Methods |
| - | - |
| `compliance:inventory:read` | [Get workspace configuration](https://docs.base44.com/api-reference/compliance/get-workspace-configuration.md), [List apps](https://docs.base44.com/api-reference/compliance/list-apps.md), [List domains](https://docs.base44.com/api-reference/compliance/list-domains.md), [List workspace API keys](https://docs.base44.com/api-reference/compliance/list-workspace-api-keys.md), [List entities](https://docs.base44.com/api-reference/compliance/list-entities.md), [List backend functions](https://docs.base44.com/api-reference/compliance/list-backend-functions.md), [List secrets](https://docs.base44.com/api-reference/compliance/list-secrets.md), [List integrations](https://docs.base44.com/api-reference/compliance/list-integrations.md), [List agents](https://docs.base44.com/api-reference/compliance/list-agents.md) |
| `compliance:members:read` | [List workspace members](https://docs.base44.com/api-reference/compliance/list-workspace-members.md) |
| `compliance:findings:read` | [List security findings](https://docs.base44.com/api-reference/compliance/list-security-findings.md) |

> [!NOTE]
>
> Some methods require multiple scopes. For example, [List workspace members](https://docs.base44.com/api-reference/compliance/list-workspace-members.md) requires both the `compliance:inventory:read` and `compliance:members:read` scopes.

If a key lacks a scope, the matching methods return a `403` `permission_error` that names the scope the method needs. For all error codes, see [Error codes](https://docs.base44.com/developers/references/compliance-api/get-started/error-codes.md).

## Send a request

Send the workspace API key and your signed authentication token with every request. This example calls the [Get Workspace Configuration Method](https://docs.base44.com/api-reference/compliance/get-workspace-configuration.md):

```bash theme={null}
curl --request GET \
  --url https://app.base44.com/api/v1/compliance/{workspace_id} \
  --header 'api_key: YOUR_API_KEY' \
  --header 'Authorization: Bearer YOUR_AUTHENTICATION_TOKEN'
```

If the request fails, see [Error codes](https://docs.base44.com/developers/references/compliance-api/get-started/error-codes.md).


## Related topics

- [Common SDK uses](https://docs.base44.com/developers/references/sdk/getting-started/work-with-sdk.md)
- [Single sign-on for enterprise workspaces](https://docs.base44.com/Enterprise/SSO-for-enterprise-workspace.md)
- [Securing your account](https://docs.base44.com/documentation/account-and-billing/securing-your-account.md)
- [Base44 client](https://docs.base44.com/developers/references/sdk/getting-started/client.md)
- [Base44 security: An overview](https://docs.base44.com/Setting-up-your-app/security-overview.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.