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

# Create Delegation

> Creates a spending delegation for the authenticated user against a previously enrolled payment method. For fiat-backed delegations (stripe/braintree/visa) the response includes a signed JWT (`delegationToken`); for crypto (erc4337) flows the token is held client-side and omitted. Requires a Nevermined API key.



## OpenAPI

````yaml POST /delegation/create
openapi: 3.1.0
info:
  title: Nevermined API
  description: >-
    API for managing AI agents, payment plans, and x402 payments in the
    Nevermined ecosystem.


    ## Prerequisites


    You need a Nevermined API Key to authenticate. Get one at
    [nevermined.app](https://nevermined.app) under **Settings > API Keys**.


    See the [5-Minute Setup Guide](/docs/integrate/quickstart/5-minute-setup)
    for detailed instructions.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.sandbox.nevermined.app/api/v1
    description: Sandbox (Testing) - Base Sepolia
  - url: https://api.live.nevermined.app/api/v1
    description: Live (Production) - Base Mainnet
security:
  - bearerAuth: []
tags:
  - name: Protocol - Agents
    description: Endpoints for registering and managing AI agents
  - name: Protocol - Plans
    description: Endpoints for creating and managing payment plans
  - name: Protocol - Credits
    description: Endpoints for minting and redeeming credits
  - name: Protocol - Access
    description: Endpoints for access tokens and request validation
  - name: X402 - Permissions
    description: Endpoints for x402 delegated permissions
paths:
  /delegation/create:
    post:
      tags:
        - Delegation
      summary: Create a spending delegation and return a signed JWT token
      description: >-
        Creates a spending delegation for the authenticated user against a
        previously enrolled payment method. For fiat-backed delegations
        (stripe/braintree/visa) the response includes a signed JWT
        (`delegationToken`); for crypto (erc4337) flows the token is held
        client-side and omitted. Requires a Nevermined API key.
      operationId: DelegationController_createDelegation
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDelegationDto'
      responses:
        '201':
          description: The created delegation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateDelegationResponseDto'
        '401':
          description: Unauthorized
components:
  schemas:
    CreateDelegationDto:
      type: object
      properties:
        provider:
          type: string
          description: >-
            Payment provider type. `stripe` / `braintree` / `visa` / `erc4337`
            select that rail directly. `vgs` (epic #1958) is a unified
            VGS-Collect card: a PLAN-AGNOSTIC, portable delegation whose
            settlement PSP (`stripe` / `braintree`) is resolved AT CHARGE TIME
            from the plan being paid (`fiatPaymentProvider`), so ONE card can
            charge ANY PSP (#2082). `delegation.provider` is persisted as the
            portable `vgs` marker (the concrete charge never sees it — the
            handler derives the real PSP at settle). Requires a portable
            `providerPaymentMethodId` (the `CRD…` cardId, which must carry an
            active network token); `planId` is OPTIONAL — pass it only to BIND
            the delegation to a single plan.
          example: stripe
          enum:
            - stripe
            - erc4337
            - braintree
            - visa
            - vgs
        providerPaymentMethodId:
          type: string
          description: >-
            Payment-method identifier from the provider. For stripe / braintree
            this is the saved card; for visa this is the VGS agentic-token id
            returned by enrollment; for vgs this is the `CRD…` canonical cardId
            from the unified VGS-Collect enroll. Required for these providers;
            ignored for erc4337.
          example: pm_1Abc2Def3Ghi4Jkl
        consumerPrompt:
          type: string
          description: >-
            Visa-only: human-readable approval prompt shown to the user during
            VGS Agentic Auth device binding. Required when provider=visa.
          example: Allow up to USD 50.00 over 5 transactions
        assuranceData:
          type: object
          description: >-
            Visa-only: opaque assurance payload from the VGS Agentic Auth
            browser SDK after FIDO/OTP device binding. Required when
            provider=visa.
        spendingLimitCents:
          type: number
          description: Maximum spending limit in cents (smallest currency unit)
          example: 10000
        durationSecs:
          type: number
          description: Duration of the delegation in seconds
          example: 604800
        currency:
          type: string
          description: Currency code (lowercase)
          example: usd
          enum:
            - usd
            - eur
            - usdc
            - eurc
        planId:
          type: string
          description: >-
            Plan ID to restrict this delegation to. Optional and plan-agnostic
            by default (#1534), INCLUDING provider=vgs (#2082): a unified VGS
            card delegation is plan-agnostic and the settlement PSP is resolved
            at charge time from the plan being paid, so one card can charge any
            PSP — pass planId only to BIND it to a single plan. EXCEPT
            provider=visa (the VGS mandate is merchant-scoped, derived from the
            plan owner; see BCK.VISA.0015), where it is REQUIRED.
          example: '123456789'
        merchantAccountId:
          type: string
          description: Optional merchant Stripe account ID to restrict payments to
          example: acct_1Abc2Def3Ghi
        maxTransactions:
          type: number
          description: Maximum number of transactions allowed (null = unlimited)
          example: 50
        apiKeyId:
          type: string
          description: Optional API Key ID (skId) to restrict this delegation to
          example: sk-abc123
        allowedRecipients:
          description: >-
            erc4337 / Router only: restrict spend to these pay-to addresses —
            the Router rejects payments to any other recipient. Omit for no
            recipient restriction.
          example:
            - '0x209693Bc6afc0C5328bA36FaF03C514EF312287C'
          type: array
          items:
            type: string
        organizationWalletId:
          type: string
          description: >-
            erc4337 / Router only (#2230): fund this delegation from an
            ORGANIZATION wallet instead of the caller's own wallet. The caller
            must be an admin of the wallet's org. Spend is always capped by the
            SPENDING member's group budget (the wallet must be shared with the
            member's group).
          example: orw-abc123
      required:
        - provider
        - spendingLimitCents
        - durationSecs
        - currency
    CreateDelegationResponseDto:
      type: object
      properties:
        delegationId:
          type: string
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        delegationToken:
          type: string
          example: eyJhbGciOiJIUzI1NiIsInR...
          nullable: true
          description: >-
            Signed JWT for fiat-backed delegations (stripe/braintree). Omitted
            for crypto (erc4337) flows where the signed delegation is held
            client-side.
      required:
        - delegationId
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your Nevermined API Key (starts with 'nvm:'). Get one at
        [nevermined.app](https://nevermined.app) under **Settings > API Keys**.

````

## Related topics

- [Delegation Selection](/docs/products/payments/mandate-selection.md)
- [x402 Delegation Extension](/docs/specs/x402-card-delegation.md)
- [X402 Protocol](/docs/api-reference/typescript/x402.md)
- [How the x402 Facilitator Works](/docs/products/x402-facilitator/how-it-works.md)
- [Automatic Credit Top-Ups](/docs/integrate/patterns/top-up.md)
