Act for Another Account
A delegate is someone an account holder allows
to act for their account, such as a lawyer working on a
client's cases. As a delegate you call the API with
your own key and name the account in the
X-DecisionLayer-Account header. The request then
reads and writes that account's cases, consent cases and
simulations as if the account had made it.
GET /api/v1/managed-accounts lists the accounts
you can act for. No key is ever created in the account
holder's name, your access is checked on every request, and
what you do is recorded under your name.
See which accounts a key can act for
Run a schema-accurate demo of
GET /api/v1/managed-accounts and inspect the JSON
immediately—no sign-in or API key required. The two accounts
in the response are made up, and nothing is read or stored.
import os
import requests
API = "https://www.decisionlayer.ai/api/v1"
KEY = {
"Authorization": (
"Bearer "
+ os.environ["DECISIONLAYER_API_KEY"]
),
}
# 1. Which accounts have made you their delegate?
accounts = requests.get(
f"{API}/managed-accounts",
headers=KEY,
timeout=30,
)
accounts.raise_for_status()
for account in accounts.json():
# 2. Name the account in a header to act for it.
# The key is still your own.
acting = {
**KEY,
"X-DecisionLayer-Account": account["id"],
}
# 3. Every call now reads and writes that
# account's cases, not yours.
cases = requests.get(
f"{API}/cases",
headers=acting,
params={"action_required": "true"},
timeout=30,
)
cases.raise_for_status()
waiting = [case["id"] for case in cases.json()]
print(account["email"], waiting)
The Run button uses a safe demo endpoint. It reads no account and never writes to the database. The account ids it returns belong to nobody, so they cannot be used with a real key. Copy the Python example when you are ready to call the real API with your own key.
Get access to an account
- 01 The account holder invites you by email at Settings › Delegates. Only they can do this; there is no API call for it.
- 02 You open the link in the invitation, sign in with the invited email address, and accept. The account then appears at Settings › Accounts I Manage.
- 03 Create an API key of your own at /settings/api-keys if you do not have one.
-
04
Call
GET /api/v1/managed-accountsand send an account'sidin theX-DecisionLayer-Accountheader.
Send your own key and the account to act for:
Authorization: Bearer dvarb_your_key_here
X-DecisionLayer-Account: 3f1c9a52-7b1e-4c0d-9a6f-2d8e5b4c1a70
What the header changes
Leave the header out and a request acts as you, exactly as before. Send it and the request acts as the account you named.
| Call | With the header |
|---|---|
| GET /me | Returns the account you are acting for. delegate names you. Call it to confirm whose account a request will touch before you file anything. |
| /cases, /consent-cases, /simulations | Read, file and respond for that account. A case you file belongs to the account, not to you. |
| GET /events | The change feed for that account's cases. Keep a separate cursor for each account. |
| POST /cases/{id}/sign | The signing document is made out to you, on behalf of the account holder. |
| GET /managed-accounts, POST /feedback | Unchanged. These two always answer for the owner of the key. |
An Idempotency-Key used while acting for one
account cannot be reused for another: the second request is
refused with 409, never answered with the first
account's result. A test key
(dvarb_test_) can act for an account too, and
what it files there is a test case.
When a call is refused
Your access is checked on every request. If the account
holder has not made you their delegate, you have not accepted
yet, or they have removed you, the call returns
403 with
reason: not_a_delegate. It is not carried out in
your own account instead, and nothing is filed.
{
"error": {
"status": 403,
"message": "This API key cannot act for that account.",
"details": [
"The key's owner is not a delegate for the account named in the X-DecisionLayer-Account header, or that access has been removed.",
"GET /api/v1/managed-accounts lists the accounts this key can act for.",
"The account holder grants access on the web at /settings/delegates, and the invitation must be accepted before it can be used."
],
"reason": "not_a_delegate"
}
}
The answer is the same for an account that does not exist, so
a key cannot be used to find out which accounts there are. A
header value that is not an account id returns
422.
The API sandbox answers these
calls with its public key,
dvarb_sandbox_public_key. That key is a delegate of one
sample account, 00000000-0000-0000-0000-000000000001: list
it, send it in the header, and send any other id to see this
refusal.
Signing, paying and identity checks
These three steps happen in a browser, not through the API.
A case object gives you the link in
action_url. As a delegate, sign in as yourself,
choose Act for this account at
Settings › Accounts I Manage,
then open the link. A banner at the top of every page shows
whose account you are in.
The account holder's email address must be verified before a
claim can be signed for them. Only they can do that, from the
link emailed to them;
email_verified on each managed account tells you
whether it is done.
AI assistants
Acting for another account is available with API keys only. An assistant connected through the MCP server always acts as the person who signed in to it.