> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.adid.dev/llms.txt.
> For full documentation content, see https://docs.adid.dev/llms-full.txt.

# Generate a delegated ZK proof on a holder's behalf

POST https://adid.dev/api/v1/zkp/delegated-proofs
Content-Type: application/json

Reference: https://docs.adid.dev/api-reference/rest-api/zkp/generate-delegated-proof

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: ida
  version: 1.0.0
paths:
  /zkp/delegated-proofs:
    post:
      operationId: generate-delegated-proof
      summary: Generate a delegated ZK proof on a holder's behalf
      tags:
        - subpackage_zkp
      parameters:
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DelegatedProofResult'
        '403':
          description: Forbidden / autonomy too low / IBCT invalid / scope mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Credential not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '410':
          description: IBCT revoked or expired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Predicate not satisfied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '501':
          description: Feature flag off and anchor=true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DelegatedProofRequest'
servers:
  - url: https://adid.dev/api/v1
  - url: http://localhost:8080/api/v1
components:
  schemas:
    ZkPredicateType:
      type: string
      enum:
        - gte
        - gt
        - lte
        - lt
        - eq
        - set_member
      title: ZkPredicateType
    ZKPredicate:
      type: object
      properties:
        attributeName:
          type: string
        type:
          $ref: '#/components/schemas/ZkPredicateType'
        value:
          description: Predicate target value (type depends on attribute).
      required:
        - attributeName
        - type
      title: ZKPredicate
    IbctType:
      type: string
      enum:
        - InvocationBoundCapabilityToken
      title: IbctType
    IBCT:
      type: object
      properties:
        id:
          type: string
        type:
          $ref: '#/components/schemas/IbctType'
        invoker:
          type: string
          description: Holder DID that authorised the agent.
        target:
          type: string
          description: Agent DID receiving the capability.
        action:
          type: string
        delegationRef:
          type: string
          description: Resolves to a delegations row id.
        nonce:
          type: string
        issuedAt:
          type: string
          format: date-time
        expiresAt:
          type: string
          format: date-time
        proofValue:
          type: string
          description: >-
            base58btc-ed25519 signature over the canonical IBCT minus
            proofValue.
      required:
        - id
        - type
        - invoker
        - target
        - action
        - delegationRef
        - nonce
        - issuedAt
        - expiresAt
        - proofValue
      description: >-
        Invocation-Bound Capability Token witnessing a holder's authorisation to
        an agent.
      title: IBCT
    DelegatedProofRequest:
      type: object
      properties:
        holderDid:
          type: string
        agentDid:
          type: string
        credentialId:
          type: string
        predicate:
          $ref: '#/components/schemas/ZKPredicate'
        ibct:
          $ref: '#/components/schemas/IBCT'
        anchor:
          type: boolean
          default: false
        syncWaitMs:
          type: integer
          default: 0
      required:
        - holderDid
        - agentDid
        - credentialId
        - predicate
        - ibct
      title: DelegatedProofRequest
    ZKProof:
      type: object
      properties:
        proof:
          type: string
        publicSignals:
          type: array
          items:
            type: string
        predicateType:
          type: string
        proofId:
          type: string
      title: ZKProof
    AnchorStatus:
      type: string
      enum:
        - pending
        - confirmed
        - revoked
        - failed
        - pre-phase7
      description: Lifecycle state of an on-chain ZK proof anchor row.
      title: AnchorStatus
    Anchor:
      type: object
      properties:
        txHash:
          type:
            - string
            - 'null'
        blockNumber:
          type:
            - integer
            - 'null'
          format: int64
        status:
          $ref: '#/components/schemas/AnchorStatus'
        revokedBlock:
          type:
            - integer
            - 'null'
          format: int64
      required:
        - status
      description: |
        Compact on-chain anchor receipt. Embedded inline in delegated-proof,
        verifications/history rows, and dashboard timeline entries when an
        anchor exists for the underlying proof.
      title: Anchor
    DelegatedProofResult:
      type: object
      properties:
        proofId:
          type: string
        delegationId:
          type: string
        proof:
          $ref: '#/components/schemas/ZKProof'
        anchor:
          oneOf:
            - $ref: '#/components/schemas/Anchor'
            - type: 'null'
      required:
        - proofId
        - delegationId
        - proof
      description: Result of a delegated proof generation, optionally including its anchor.
      title: DelegatedProofResult
    ErrorError:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        details:
          type: object
          additionalProperties:
            description: Any type
      title: ErrorError
    Error:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorError'
      title: Error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

```

## SDK Code Examples

```python
import requests

url = "https://adid.dev/api/v1/zkp/delegated-proofs"

payload = {
    "holderDid": "did:example:holder123456789",
    "agentDid": "did:example:agent987654321",
    "credentialId": "cred-1234abcd5678efgh",
    "predicate": {
        "attributeName": "age",
        "type": "gte"
    },
    "ibct": {
        "id": "urn:uuid:ibct-9a7b6c5d-4e3f-2a1b-0c9d-8e7f6a5b4c3d",
        "type": "InvocationBoundCapabilityToken",
        "invoker": "did:example:holder123456789",
        "target": "did:example:agent987654321",
        "action": "zkp.predicate.age",
        "delegationRef": "delegation-5678efgh1234abcd",
        "nonce": "f3a1b2c4d5e6f789",
        "issuedAt": "2024-01-15T09:30:00Z",
        "expiresAt": "2024-07-15T09:30:00Z",
        "proofValue": "zQ3x7v9P"
    }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://adid.dev/api/v1/zkp/delegated-proofs';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"holderDid":"did:example:holder123456789","agentDid":"did:example:agent987654321","credentialId":"cred-1234abcd5678efgh","predicate":{"attributeName":"age","type":"gte"},"ibct":{"id":"urn:uuid:ibct-9a7b6c5d-4e3f-2a1b-0c9d-8e7f6a5b4c3d","type":"InvocationBoundCapabilityToken","invoker":"did:example:holder123456789","target":"did:example:agent987654321","action":"zkp.predicate.age","delegationRef":"delegation-5678efgh1234abcd","nonce":"f3a1b2c4d5e6f789","issuedAt":"2024-01-15T09:30:00Z","expiresAt":"2024-07-15T09:30:00Z","proofValue":"zQ3x7v9P"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://adid.dev/api/v1/zkp/delegated-proofs"

	payload := strings.NewReader("{\n  \"holderDid\": \"did:example:holder123456789\",\n  \"agentDid\": \"did:example:agent987654321\",\n  \"credentialId\": \"cred-1234abcd5678efgh\",\n  \"predicate\": {\n    \"attributeName\": \"age\",\n    \"type\": \"gte\"\n  },\n  \"ibct\": {\n    \"id\": \"urn:uuid:ibct-9a7b6c5d-4e3f-2a1b-0c9d-8e7f6a5b4c3d\",\n    \"type\": \"InvocationBoundCapabilityToken\",\n    \"invoker\": \"did:example:holder123456789\",\n    \"target\": \"did:example:agent987654321\",\n    \"action\": \"zkp.predicate.age\",\n    \"delegationRef\": \"delegation-5678efgh1234abcd\",\n    \"nonce\": \"f3a1b2c4d5e6f789\",\n    \"issuedAt\": \"2024-01-15T09:30:00Z\",\n    \"expiresAt\": \"2024-07-15T09:30:00Z\",\n    \"proofValue\": \"zQ3x7v9P\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://adid.dev/api/v1/zkp/delegated-proofs")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"holderDid\": \"did:example:holder123456789\",\n  \"agentDid\": \"did:example:agent987654321\",\n  \"credentialId\": \"cred-1234abcd5678efgh\",\n  \"predicate\": {\n    \"attributeName\": \"age\",\n    \"type\": \"gte\"\n  },\n  \"ibct\": {\n    \"id\": \"urn:uuid:ibct-9a7b6c5d-4e3f-2a1b-0c9d-8e7f6a5b4c3d\",\n    \"type\": \"InvocationBoundCapabilityToken\",\n    \"invoker\": \"did:example:holder123456789\",\n    \"target\": \"did:example:agent987654321\",\n    \"action\": \"zkp.predicate.age\",\n    \"delegationRef\": \"delegation-5678efgh1234abcd\",\n    \"nonce\": \"f3a1b2c4d5e6f789\",\n    \"issuedAt\": \"2024-01-15T09:30:00Z\",\n    \"expiresAt\": \"2024-07-15T09:30:00Z\",\n    \"proofValue\": \"zQ3x7v9P\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://adid.dev/api/v1/zkp/delegated-proofs")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"holderDid\": \"did:example:holder123456789\",\n  \"agentDid\": \"did:example:agent987654321\",\n  \"credentialId\": \"cred-1234abcd5678efgh\",\n  \"predicate\": {\n    \"attributeName\": \"age\",\n    \"type\": \"gte\"\n  },\n  \"ibct\": {\n    \"id\": \"urn:uuid:ibct-9a7b6c5d-4e3f-2a1b-0c9d-8e7f6a5b4c3d\",\n    \"type\": \"InvocationBoundCapabilityToken\",\n    \"invoker\": \"did:example:holder123456789\",\n    \"target\": \"did:example:agent987654321\",\n    \"action\": \"zkp.predicate.age\",\n    \"delegationRef\": \"delegation-5678efgh1234abcd\",\n    \"nonce\": \"f3a1b2c4d5e6f789\",\n    \"issuedAt\": \"2024-01-15T09:30:00Z\",\n    \"expiresAt\": \"2024-07-15T09:30:00Z\",\n    \"proofValue\": \"zQ3x7v9P\"\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://adid.dev/api/v1/zkp/delegated-proofs', [
  'body' => '{
  "holderDid": "did:example:holder123456789",
  "agentDid": "did:example:agent987654321",
  "credentialId": "cred-1234abcd5678efgh",
  "predicate": {
    "attributeName": "age",
    "type": "gte"
  },
  "ibct": {
    "id": "urn:uuid:ibct-9a7b6c5d-4e3f-2a1b-0c9d-8e7f6a5b4c3d",
    "type": "InvocationBoundCapabilityToken",
    "invoker": "did:example:holder123456789",
    "target": "did:example:agent987654321",
    "action": "zkp.predicate.age",
    "delegationRef": "delegation-5678efgh1234abcd",
    "nonce": "f3a1b2c4d5e6f789",
    "issuedAt": "2024-01-15T09:30:00Z",
    "expiresAt": "2024-07-15T09:30:00Z",
    "proofValue": "zQ3x7v9P"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://adid.dev/api/v1/zkp/delegated-proofs");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"holderDid\": \"did:example:holder123456789\",\n  \"agentDid\": \"did:example:agent987654321\",\n  \"credentialId\": \"cred-1234abcd5678efgh\",\n  \"predicate\": {\n    \"attributeName\": \"age\",\n    \"type\": \"gte\"\n  },\n  \"ibct\": {\n    \"id\": \"urn:uuid:ibct-9a7b6c5d-4e3f-2a1b-0c9d-8e7f6a5b4c3d\",\n    \"type\": \"InvocationBoundCapabilityToken\",\n    \"invoker\": \"did:example:holder123456789\",\n    \"target\": \"did:example:agent987654321\",\n    \"action\": \"zkp.predicate.age\",\n    \"delegationRef\": \"delegation-5678efgh1234abcd\",\n    \"nonce\": \"f3a1b2c4d5e6f789\",\n    \"issuedAt\": \"2024-01-15T09:30:00Z\",\n    \"expiresAt\": \"2024-07-15T09:30:00Z\",\n    \"proofValue\": \"zQ3x7v9P\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "holderDid": "did:example:holder123456789",
  "agentDid": "did:example:agent987654321",
  "credentialId": "cred-1234abcd5678efgh",
  "predicate": [
    "attributeName": "age",
    "type": "gte"
  ],
  "ibct": [
    "id": "urn:uuid:ibct-9a7b6c5d-4e3f-2a1b-0c9d-8e7f6a5b4c3d",
    "type": "InvocationBoundCapabilityToken",
    "invoker": "did:example:holder123456789",
    "target": "did:example:agent987654321",
    "action": "zkp.predicate.age",
    "delegationRef": "delegation-5678efgh1234abcd",
    "nonce": "f3a1b2c4d5e6f789",
    "issuedAt": "2024-01-15T09:30:00Z",
    "expiresAt": "2024-07-15T09:30:00Z",
    "proofValue": "zQ3x7v9P"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://adid.dev/api/v1/zkp/delegated-proofs")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```