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

# Create a pay-in session

> Start a hosted fiat-to-crypto pay-in and get a payment URL.

Creates a hosted pay-in session. Redirect the payer to the returned `paymentUrl`; on completion the fiat is converted to the chosen cryptocurrency and credited to the account's wallet. Provide a `callbackUrl` and a unique `idempotencyKey` ([safe retries](/getting-started/conventions#idempotency)).

<Note>The account must be **verified** before a pay-in session can be created. See [Account verification](/guides/finance/kyc-verification).</Note>


## OpenAPI

````yaml api-reference/Finance-API-Specs.yaml POST /accounts/{accountId}/fiat-to-crypto/payment-sessions
openapi: 3.1.0
info:
  title: Venly Finance API
  description: >
    REST API for the Venly Finance platform:

    - Party management (Individuals & Organisations)

    - Account management with party association

    - Wallet balances & token allowances on supported chains (Base, Avalanche)

    - Virtual bank account assignment for global payments (EUR SEPA)

    - Fiat-to-crypto payment sessions (pay-in)

    - Account-to-account fiat & crypto transfers

    - EIP-2612 permits and payment requests


    ## Authentication


    All endpoints use OAuth2 client credentials. Obtain a token first, then
    include it in every request:


    **Step 1 — Get a token:**

    ```bash

    curl -X POST
    https://login.venly.io/auth/realms/VenlyFinance/protocol/openid-connect/token
    \
      -H "Content-Type: application/x-www-form-urlencoded" \
      -d "grant_type=client_credentials&client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}"
    ```


    **Step 2 — Use the token:**

    ```

    Authorization: Bearer {access_token}

    ```


    Tokens expire after **5 minutes**. Implement refresh logic in your client.
  version: 1.1.0
  contact:
    name: Venly Support
    email: support@venly.io
    url: https://docs.venlyfinance.com
  license:
    name: Proprietary
  x-logo:
    url: https://venlyfinance.com/logo.png
  x-security-contact: security@venly.io
servers:
  - url: https://api.venlyfinance.com/v1
    description: Production
  - url: https://api-staging.venlyfinance.com/v1
    description: Staging
security:
  - OAuth2: []
tags:
  - name: Parties
    description: Party management (Individuals & Organisations)
  - name: Accounts
    description: Account management, party-role associations
  - name: Wallets
    description: Blockchain wallet balances
  - name: Virtual Bank Accounts
    description: Virtual bank account payment references for global payments
  - name: Fiat-to-crypto Payment Sessions
    description: Fiat-to-crypto payment session creation
  - name: Payment Requests
    description: Payment request management for card provider integrations
  - name: Transfers
    description: Fiat and crypto transfer operations between accounts
  - name: Permits
    description: EIP-712 permit signature management for token approvals
  - name: Allowances
    description: Token allowance management for wallets
paths:
  /accounts/{accountId}/fiat-to-crypto/payment-sessions:
    post:
      tags:
        - Fiat-to-crypto Payment Sessions
      summary: Create a fiat-to-crypto payment session
      description: >
        Creates a hosted pay-in session. The response includes a `paymentUrl` to
        redirect the

        payer to; on completion the incoming fiat is converted to the chosen
        cryptocurrency and

        credited to the account's wallet. `callbackUrl` and a UUID
        `idempotencyKey` are required.
      operationId: createPayInSession
      parameters:
        - $ref: '#/components/parameters/AccountId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePayInSessionRequest'
            example:
              inAmount: '100.00'
              inCurrency: EUR
              outCryptocurrency: USDC
              callbackUrl: https://example.com/webhooks/pay-in
              successRedirectUrl: https://example.com/pay-in/success
              failureRedirectUrl: https://example.com/pay-in/failure
              externalRef: order-67890
              idempotencyKey: 3fa85f64-5717-4562-b3fc-2c963f66afa6
      responses:
        '201':
          description: Payment session created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SinglePaymentSessionResponse'
              example:
                success: true
                result:
                  id: 5e6f7081-92a3-4b4c-8d5e-6f708192a3b4
                  accountId: b2a1f0e9-8c7d-4e3a-9f21-0a1b2c3d4e5f
                  status: CREATED
                  inAmount: 100
                  inCurrency: EUR
                  outCryptocurrency: USDC
                  paymentUrl: https://pay.example.com/session/5e6f708192a3b4c8
                  externalRef: order-67890
                  walletId: 9f8e7d6c-5b4a-4938-8271-6a5b4c3d2e1f
                  blockchainTxId: null
                  cancellable: true
                  expiresAt: '2026-01-15T10:30:00Z'
                  metadata:
                    orderId: '67890'
                  idempotencyKey: 3fa85f64-5717-4562-b3fc-2c963f66afa6
                  createdAt: '2026-01-15T09:30:00'
                  updatedAt: '2026-01-15T09:30:00'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          description: Unsupported currency pair or KYC required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    AccountId:
      name: accountId
      in: path
      required: true
      description: Unique account identifier
      schema:
        type: string
        format: uuid
      example: b2a1f0e9-8c7d-4e3a-9f21-0a1b2c3d4e5f
  schemas:
    CreatePayInSessionRequest:
      type: object
      required:
        - inAmount
        - inCurrency
        - outCryptocurrency
        - callbackUrl
        - idempotencyKey
      properties:
        inAmount:
          type: string
          pattern: ^\d+(\.\d{1,2})?$
          description: Fiat amount to pay in
        inCurrency:
          type: string
          minLength: 1
          description: Fiat currency of the incoming payment (e.g. EUR)
        outCryptocurrency:
          type: string
          minLength: 1
          description: Cryptocurrency to convert the incoming fiat to (e.g. USDC)
        callbackUrl:
          type: string
          pattern: ^https://.*
          description: HTTPS URL to receive payment status callbacks
        successRedirectUrl:
          type: string
          description: URL to redirect the user to on successful payment
        failureRedirectUrl:
          type: string
          description: URL to redirect the user to on failed payment
        externalRef:
          type: string
          maxLength: 255
          description: Optional external reference
        idempotencyKey:
          type: string
          format: uuid
          description: Unique UUID key to prevent duplicate operations on retry
        metadata:
          type: object
          additionalProperties:
            type: string
    SinglePaymentSessionResponse:
      allOf:
        - $ref: '#/components/schemas/BaseResponse'
        - type: object
          properties:
            result:
              $ref: '#/components/schemas/PaymentSession'
    ErrorResponse:
      type: object
      description: Error response wrapper
      properties:
        success:
          type: boolean
          description: Always false for error responses
          example: false
        errors:
          type: array
          description: List of errors that occurred
          items:
            $ref: '#/components/schemas/ErrorBody'
        result:
          type: object
          nullable: true
          description: Null or omitted when success is false
    BaseResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Indicates whether the request was successful
    PaymentSession:
      type: object
      properties:
        id:
          type: string
          format: uuid
        accountId:
          type: string
          format: uuid
        status:
          $ref: '#/components/schemas/PaymentSessionStatus'
        inAmount:
          type: number
          description: Fiat amount to be paid in
        inCurrency:
          type: string
          description: Fiat currency of the incoming payment
        outCryptocurrency:
          type: string
          description: Cryptocurrency the incoming fiat is converted to
        paymentUrl:
          type: string
          format: uri
          description: Hosted URL to redirect the payer to
        externalRef:
          type: string
        walletId:
          type: string
          format: uuid
        blockchainTxId:
          type: string
          nullable: true
        cancellable:
          type: boolean
        expiresAt:
          type: string
          format: date-time
        metadata:
          type: object
          additionalProperties:
            type: string
        idempotencyKey:
          type: string
          format: uuid
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    ErrorBody:
      type: object
      description: Individual error details
      properties:
        code:
          type: string
          description: Machine-readable error code
          example: invalid-request
        message:
          type: string
          description: Human-readable error message
          example: The request contains invalid parameters.
    PaymentSessionStatus:
      type: string
      description: Status of a fiat-to-crypto payment session
      enum:
        - CREATED
        - PENDING_PAYMENT
        - PAYMENT_RECEIVED
        - CONVERTING
        - MINTING
        - COMPLETED
        - FAILED
        - EXPIRED
        - CANCELLED
        - REFUNDING
        - REFUNDED
  responses:
    BadRequest:
      description: Request validation failed (400)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            errors:
              - code: invalid-request
                message: The request contains invalid parameters.
    Unauthorized:
      description: Authentication required or failed (401)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            errors:
              - code: unauthenticated
                message: Please authenticate to perform this action.
    Forbidden:
      description: Caller lacks the required authority/role (403)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            errors:
              - code: forbidden
                message: You do not have permission to access this resource.
    NotFound:
      description: Resource not found (404)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            errors:
              - code: account-not-found
                message: The requested resource was not found.
    InternalServerError:
      description: Unexpected server error (500)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            errors:
              - code: internal-error
                message: An unexpected error occurred. Please try again later.
  securitySchemes:
    OAuth2:
      type: oauth2
      description: >
        OAuth2 client credentials flow. Token endpoints:

        - Staging:
        https://login-staging.venly.io/auth/realms/VenlyFinance/protocol/openid-connect/token

        - Production:
        https://login.venly.io/auth/realms/VenlyFinance/protocol/openid-connect/token
      flows:
        clientCredentials:
          tokenUrl: >-
            https://login-staging.venly.io/auth/realms/VenlyFinance/protocol/openid-connect/token
          scopes: {}

````