# Register your agent's calls

Let your agent's phone calls carry proof. Verify the number it calls from, give its grant a call scope, and register each call with a credential signed by the agent's key before it dials.

Register a call before your agent dials, so the business that answers can check which agent is calling, who operates it and what its person allowed. The agent signs a short-lived call credential with its key, and Provenance returns a 6-digit short code for the agent to speak if asked. Registering is free.

**Before you begin:** register the agent and publish its Ed25519 key, as in [sign your agent's requests](https://provenanceauth.com/docs/identify/guides/sign-agent-requests.md). The steps below use the sandbox account key, and calls go from `+14155550100` to a business line at `+14155550123`.

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
```

1. **Your agent**: signs the call credential
2. **Provenance**: checks it and returns the short code
3. **The business**: checks the call as it rings

## 1. Verify the number your agent calls from

Add the number with `side: caller`. Provenance texts it a 6-digit code, or reads the code out on a call with `channel: call` for a landline or a contact-centre line. A key needs the `mandate` scope.

**curl**

```bash
curl -s -X POST $PROVENANCE_API/v1/mandate/call_numbers \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "number": "+14155550100", "side": "caller" }' | tee number.json
export NUMBER_ID=$(jq -r .id number.json)
```

**Node**

```ts
import { Provenance } from "@provenanceauth/sdk";

const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
const number = await prov.mandate.callNumbers.create({ number: "+14155550100", side: "caller" });
```

**Python**

```python
import os
from provenanceauth import Provenance

prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=os.environ["PROVENANCE_API"])
number = prov.mandate.call_numbers.create(number="+14155550100", side="caller")
```

```json
{
  "id": "cnum_01M6XS88KR3S50F75T14QJ6DQ4",
  "object": "call_number",
  "side": "caller",
  "last4": "0100",
  "country": "US",
  "status": "pending",
  "channel": "sms",
  "verified_at": null,
  "created_at": "2026-11-08T14:33:29.976Z",
  "delivery": { "channel": "sms", "delivered": false, "reason": "channel_not_configured" }
}
```

`delivery` says whether the code went out. Then send the code back within 10 minutes; you have 5 tries:

**curl**

```bash norun
curl -s -X POST $PROVENANCE_API/v1/mandate/call_numbers/$NUMBER_ID/verify \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "code": "204135" }'
```

**Node**

```ts
await prov.mandate.callNumbers.verify(number.id, "204135");
```

**Python**

```python
prov.mandate.call_numbers.verify(number["id"], "204135")
```

```json
{
  "id": "cnum_01M6XS88KR3S50F75T14QJ6DQ4",
  "object": "call_number",
  "side": "caller",
  "status": "verified",
  "verified_at": "2026-11-08T14:33:29.990Z"
}
```

The number stores as a keyed hash plus its last four digits. When another account later verifies the same number, it moves to that account.

## 2. Give the grant a call scope

A call registers against a grant whose constraints include `calls`, or against a one-time approval. The call scope stays on the grant on the server and never enters the grant token.

- `purposes` (string[]): Required. The purposes the agent may call for, from the closed list on the [call credential reference](https://provenanceauth.com/docs/authorize/reference/call-credential.md#claims).
- `counterparties` (string[]): Numbers in E.164, or business names verified by the line's owner. Leave it out to allow any number.
- `max_amount` (integer): The most the agent may commit to on a call, in minor units, with `currency`. A business that asks for more reaches the person.
- `max_calls_per_day` (integer): Calls a day under this grant, counted in the scope's time zone.
- `hours` (object): `{ tz, schedule }`: the weekly hours the agent may call, such as `{ "mon": [["09:00", "18:00"]] }`.

**curl**

```bash
curl -s -X POST $PROVENANCE_API/v1/mandate/grants \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "device_id": "dev_00000000000000000000000000000001",
    "constraints": {
      "expires_at": "2027-06-30T00:00:00Z",
      "calls": { "purposes": ["book", "cancel"], "counterparties": ["Bistro Nine"], "max_amount": 20000, "currency": "USD", "max_calls_per_day": 5 }
    }
  }' | tee grant.json
export GRANT_ID=$(jq -r .id grant.json)
```

**Node**

```ts
const grant = await prov.mandate.grants.create({
  device_id: "dev_00000000000000000000000000000001",
  constraints: {
    expires_at: "2027-06-30T00:00:00Z",
    calls: { purposes: ["book", "cancel"], counterparties: ["Bistro Nine"], max_amount: 20000, currency: "USD", max_calls_per_day: 5 },
  },
});
```

**Python**

```python
grant = prov.mandate.grants.create(
    device_id="dev_00000000000000000000000000000001",
    constraints={
        "expires_at": "2027-06-30T00:00:00Z",
        "calls": {"purposes": ["book", "cancel"], "counterparties": ["Bistro Nine"], "max_amount": 20000, "currency": "USD", "max_calls_per_day": 5},
    },
)
```

```json
{
  "object": "grant",
  "status": "active",
  "device_id": "dev_00000000000000000000000000000001"
}
```

In production the grant names the agent with `agent_id`, so only that agent can call under it.

## 3. Register the call before dialing

Sign the call credential with the agent's private key and post it. The credential binds both numbers, a window of 15 minutes at most that starts within 60 seconds of now, the purpose and the grant. The format is on the [call credential reference](https://provenanceauth.com/docs/authorize/reference/call-credential.md).

The `registerCall` helper in `@provenanceauth/agent-adapters` builds the claims, signs them and posts them in one call. With the SDK, `signCallCredential` signs and `mandate.calls.register` posts:

**curl**

```bash norun
# CREDENTIAL is the compact JWS your agent signed (alg EdDSA, typ call+jws)
curl -s -X POST $PROVENANCE_API/v1/mandate/calls \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d "{ \"credential\": \"$CREDENTIAL\" }"
```

**Node**

```ts
import { registerCall } from "@provenanceauth/agent-adapters";

const call = await registerCall({
  client: prov,
  agent: { id: agentId, privateJwk },
  from: "+14155550100",
  to: "+14155550123",
  purpose: "book",
  purposeText: "Table for 2 at 7pm Friday",
  grant: grant.id,
  disclosure: { ai: true, statement: "spoken_at_start" },
  consent: { basis: "customer_request", ref: "booking-4471" },
});
```

**Python**

```python
import time, uuid
from provenanceauth import sign_call_credential

now = int(time.time())
credential = sign_call_credential(private_jwk, {
    "v": 1, "iss": directory_url, "agent": agent_id,
    "from": "+14155550100", "to": "+14155550123", "nbf": now, "exp": now + 600, "jti": str(uuid.uuid4()),
    "purpose": "book", "purpose_text": "Table for 2 at 7pm Friday", "grant": grant["id"],
    "disclosure": {"ai": True, "statement": "spoken_at_start"},
    "consent": {"basis": "customer_request", "ref": "booking-4471"},
})
call = prov.mandate.calls.register(credential=credential)
```

```json
{
  "id": "call_01M6XS88MWEMC2TK5MM9Y9MAWE",
  "object": "call",
  "status": "registered",
  "agent_id": "agt_01M6XS88KNFTWDGP2MRBSJG3WR",
  "purpose": "book",
  "short_code": "512656",
  "not_before": "2026-11-08T14:33:30.000Z",
  "expires_at": "2026-11-08T14:43:30.000Z",
  "person_approved": true,
  "grant_id": "grt_01M6XS88MSV3GBK874W606KSBA",
  "approval_id": null,
  "created_at": "2026-11-08T14:33:30.011Z"
}
```

`short_code` is returned only here. Keep it for the call: when a business asks for proof, the agent speaks the digits or keys them as tones. Every attempt writes one row to your [decision ledger](https://provenanceauth.com/docs/mandate/concepts/decision-ledger.md).

A refusal is a `200` with `status: refused` and a reason code, and nothing is registered:

```json
{
  "id": null,
  "object": "call",
  "status": "refused",
  "reason": "call_purpose_not_allowed",
  "message": "the grant allows book, cancel",
  "decision_id": "mas_01M6XS88P6BKRJDS6PN8EA08EM"
}
```

`disclosure` and `consent` are records your agent carries into the verdict and the receipt. They are designed to support disclosure and consent rules for AI-voiced calls; your agent still has to meet the rules that apply to it, such as saying it is an AI.

## 4. Answer a business's challenge

A business that gets a call your agent didn't register can challenge it. Its receptionist says "Please verify this call with Provenance, code 6-7-5-8-0-7." and plays the tones `*675807#`. The last digit is a check digit, so a misheard code is caught before anything is sent.

`listenForChallenge()` in `@provenanceauth/sdk` finds the phrase in your agent's transcript or the tones in its keypad events. Register the call with that code as `challenge_code`, and the business's waiting check turns `verified`:

**curl**

```bash norun
curl -s -X POST $PROVENANCE_API/v1/mandate/calls \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d "{ \"credential\": \"$CREDENTIAL\", \"challenge_code\": \"675807\" }"
```

**Node**

```ts
import { listenForChallenge } from "@provenanceauth/sdk";
import { registerCall } from "@provenanceauth/agent-adapters";

const heard = listenForChallenge({ transcript: lastBusinessTurn });
if (heard) {
  await registerCall({ client: prov, agent, from, to, purpose: "book", grant: grant.id, challengeCode: heard.code });
}
```

**Python**

```python
call = prov.mandate.calls.register(credential=credential, challenge_code="675807")
```

```json
{
  "id": "call_01M6XS88QCHCQC7EGM8KS6XV1T",
  "object": "call",
  "status": "registered",
  "short_code": "625375",
  "person_approved": true,
  "answered_check_id": "ccx_01M6XS88PYFZ9T119KKNHFF5KD"
}
```

A wrong code registers nothing and uses one of the challenge's 5 tries. Agents that speak MCP can use the `answer_call_challenge` tool in `@provenanceauth/mcp-server`, which signs and registers in one step.

## 5. Handle proof requests and revoke calls

When a business challenges a call from your verified number, your webhook endpoints subscribed to `mandate.call.proof_requested` get the event with `proof_request_id` and the last four digits of both numbers. If one of your agents is on that call, register it, and the waiting check matches. If none is, decline the request: the business's check returns `no_proof`, and you get `mandate.call.spoof_suspected`.

**curl**

```bash norun
curl -s -X POST $PROVENANCE_API/v1/mandate/calls/proof_requests/ccx_01M6XS88R5FRAGAMTCFZBXJVT2/decline \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "reason": "not_ours" }'
```

**Node**

```ts
await prov.mandate.calls.declineProofRequest("ccx_01M6XS88R5FRAGAMTCFZBXJVT2");
```

**Python**

```python
prov.mandate.calls.decline_proof_request("ccx_01M6XS88R5FRAGAMTCFZBXJVT2")
```

```json
{
  "id": "ccx_01M6XS88R5FRAGAMTCFZBXJVT2",
  "object": "call_proof_request",
  "status": "declined",
  "created_at": "2026-11-08T14:33:30.117Z"
}
```

`answerProofRequest()` in `@provenanceauth/agent-adapters` matches the event to your agent's open calls and does one or the other. To stop a registered call from verifying, revoke it with [`POST /v1/mandate/calls/{id}/revoke`](https://provenanceauth.com/docs/api/calls.md#post-v1-mandate-calls-id-revoke). Revoking the grant or suspending the agent revokes its open calls too.

## Errors you might see

| Symptom | Cause | Fix |
| --- | --- | --- |
| `call_number_unverified` refusal | `from` isn't a caller number your account verified | Verify it (step 1), then register again. |
| `call_window_invalid` refusal | The window is over 15 minutes, or `nbf` is more than 60 seconds from now | Sign the credential as the agent dials, with a window of 15 minutes or less. |
| `call_signature_invalid` refusal | The signature, `kid` or `iss` doesn't match the agent's published key | Sign with the key you published, and set `iss` to the agent's directory. |
| `call_purpose_not_allowed` refusal | The grant's call scope doesn't list this purpose | Ask the person for a wider grant or a one-time approval. |
| `call_counterparty_not_allowed` refusal | The number called isn't one of the grant's counterparties | Ask the person to add the business. |
| `call_outside_hours` refusal | The call starts outside the grant's hours | Call within the hours, or ask for a one-time approval. |
| `call_daily_limit` refusal | The grant's calls for today are used | Wait for tomorrow, or ask for a one-time approval. |
| `call_challenge_invalid` refusal | The challenge code is wrong, or no challenge is open for these numbers | Ask the business to repeat the code. |
| `call_number_code_invalid` (400) | The number's code is wrong, expired or out of tries | Add the number again for a new code. |
| `directory_unavailable` (503) | An agent with its own directory: the directory didn't answer | Serve the keys over https and register again. |
| `calls_not_configured` (503) | Verified calls aren't turned on for this deployment | Treat the call as unregistered. |

## See also

- [Verified calls](https://provenanceauth.com/docs/authorize/concepts/verified-calls.md)
- [Verify AI callers](https://provenanceauth.com/docs/authorize/guides/verify-ai-callers.md), the business's side
- [Call credential format](https://provenanceauth.com/docs/authorize/reference/call-credential.md)
- [Grants](https://provenanceauth.com/docs/mandate/concepts/grants.md)
- [Webhooks](https://provenanceauth.com/docs/integrate/webhooks.md)
