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

# Create a payment or deposit



## OpenAPI

````yaml /api-reference/openapi.json post /v1/external/secretkey-auth/payments
openapi: 3.0.0
info:
  title: SpacePay External API
  description: Merchant-facing SpacePay API endpoints.
  version: '1.0'
servers:
  - url: https://api.spacepay.solutions
    description: Mainnet
  - url: https://api-testnet.spacepay.solutions
    description: Testnet
security: []
tags:
  - name: External - Token Registry (Public)
  - name: External - Payments (Secret Key)
  - name: External - Withdrawals (Secret Key)
  - name: External - Wallet (Secret Key)
paths:
  /v1/external/secretkey-auth/payments:
    post:
      tags:
        - External - Payments (Secret Key)
      summary: Create a payment or deposit
      operationId: ExternalPaymentsBySecretKeyController_createPayment
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePaymentRequestDto'
      responses:
        '201':
          description: Payment created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatePaymentResponseDto'
        '400':
          description: Invalid input data
        '401':
          description: Invalid or missing x-spacepay-secret-key header
        '409':
          description: Idempotency conflict (in-progress or payload mismatch)
      security:
        - Secret Key: []
components:
  schemas:
    CreatePaymentRequestDto:
      type: object
      properties:
        type:
          enum:
            - payment
            - deposit
          type: string
          description: >-
            Type of the payment. "payment" requires a fixed amount; "deposit"
            accepts any amount sent by the customer.
          default: payment
        amount:
          type: number
          minimum: 400
          maximum: 100000000
          description: >-
            Payment amount in cents (e.g., 100 = $1.00). Required for type
            "payment", ignored for type "deposit". Minimum: 400 cents, Maximum:
            100000000 cents.
          example: 400
        currency:
          type: string
          enum:
            - USD
          description: The currency of the payment. Only USD is supported.
          example: USD
        orderId:
          type: string
          maxLength: 255
          description: The order ID from the merchant
          example: Order_1234567890
        customerRefId:
          type: string
          maxLength: 255
          description: >-
            Stable customer identifier for deposits: the same value reuses the
            same deposit wallet across a customer's deposits (scoped to the
            merchant). Ignored for checkout (PAYMENT-type) payments.
          example: customer_42
        redirectUrl:
          type: string
          maxLength: 2048
          format: uri
          description: URL to redirect the customer to after successful payment
          example: https://merchant.example.com/checkout/success
        customMetadata:
          type: string
          maxLength: 2048
          description: Arbitrary metadata to append to the redirect URL as a query string
          example: '{"cartId":"abc123","promo":"SUMMER24"}'
      required:
        - currency
        - orderId
    CreatePaymentResponseDto:
      type: object
      properties:
        paymentUrl:
          type: string
          description: >-
            URL of the payment screen where the customer can complete the
            payment
          example: >-
            https://spacepay.example.com/payment?paymentId=1234567890&secret=1234567890
        secret:
          type: string
          description: Secret of the payment
          example: '1234567890'
        paymentId:
          type: string
          description: Payment ID
          example: '1234567890'
        payment:
          description: Payment
          allOf:
            - $ref: '#/components/schemas/MerchantPaymentDto'
      required:
        - paymentUrl
        - secret
        - paymentId
        - payment
    MerchantPaymentDto:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Payment ID
        merchantId:
          type: string
          format: uuid
          description: Merchant ID
        merchantShortName:
          type: string
          description: Merchant short name
        merchantLogoUrl:
          type: string
          nullable: true
          description: Merchant logo URL
        type:
          enum:
            - payment
            - deposit
          type: string
          description: Payment type
        amountInCents:
          type: number
          description: Payment amount in cents
        amountDueCents:
          type: number
          description: >-
            Amount due in cents. Provisional until a quote is paid, then
            finalized to the paid quote (chain-specific convenience fee).
        convenienceFeeCents:
          type: number
          nullable: true
          description: >-
            Convenience fee in cents charged to the buyer. Null until the
            payment settles.
        merchantFeeCents:
          type: number
          nullable: true
          description: >-
            Merchant fee in cents deducted from the merchant. Null until the
            payment settles.
        swapFeeCents:
          type: number
          nullable: true
          description: >-
            Swap fee in cents deducted from the merchant. Null until the payment
            settles.
        currency:
          type: string
          enum:
            - USD
          description: Currency of the payment
        status:
          enum:
            - pending
            - processing
            - completed
            - failed
            - expired
            - cancelled
          type: string
          description: Payment status
        quotes:
          description: Quotes
          type: array
          items:
            $ref: '#/components/schemas/PaymentQuoteDto'
        receipt:
          nullable: true
          description: Receipt
          allOf:
            - $ref: '#/components/schemas/PaymentReceiptDto'
        orderId:
          type: string
          nullable: true
          description: Order ID
        redirectUrl:
          type: string
          nullable: true
          description: Redirect URL
        createdAt:
          format: date-time
          type: string
          description: Created at
        amountMerchantNetCents:
          type: number
          description: Amount the merchant receives after fees, in cents
      required:
        - id
        - merchantId
        - merchantShortName
        - merchantLogoUrl
        - type
        - amountInCents
        - amountDueCents
        - convenienceFeeCents
        - merchantFeeCents
        - swapFeeCents
        - currency
        - status
        - quotes
        - receipt
        - orderId
        - redirectUrl
        - createdAt
        - amountMerchantNetCents
    PaymentQuoteDto:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Quote ID
        paymentId:
          type: string
          format: uuid
          description: Payment ID
        token:
          description: Token
          allOf:
            - $ref: '#/components/schemas/TokenDto'
        chainId:
          type: string
          description: CAIP-2 chain id
          example: eip155:1
        depositAddress:
          description: Deposit address for this quote
          allOf:
            - $ref: '#/components/schemas/DepositAddressDto'
        expectedAmountAsset:
          type: string
          description: Expected amount asset
        rateUsdAsset:
          type: number
          description: Rate USD asset
        amountDueCents:
          type: number
          nullable: true
          description: >-
            Amount the buyer pays for this quote in cents, including the
            convenience fee. Null for quotes without a resolved fee breakdown.
        expiresAt:
          format: date-time
          type: string
          description: Expires at
        status:
          enum:
            - active
            - expired
            - used
            - failed
          type: string
          description: Status
        createdAt:
          format: date-time
          type: string
          description: Created at
      required:
        - id
        - paymentId
        - token
        - chainId
        - depositAddress
        - expectedAmountAsset
        - rateUsdAsset
        - amountDueCents
        - expiresAt
        - status
        - createdAt
    PaymentReceiptDto:
      type: object
      properties:
        paymentId:
          type: string
          format: uuid
          description: Payment ID
        selectedQuote:
          description: Selected quote
          allOf:
            - $ref: '#/components/schemas/PaymentQuoteDto'
        settledToken:
          description: Settled token
          allOf:
            - $ref: '#/components/schemas/TokenDto'
        settledChain:
          description: Settled chain
          allOf:
            - $ref: '#/components/schemas/ChainDto'
        settledAmountAsset:
          type: string
          description: Settled amount in asset
          example: '100'
        settledAmountUsd:
          type: string
          description: Settled amount in USD
          example: '100.00'
        txHash:
          type: string
          nullable: true
          description: Transaction hash
          example: '0xda3be87732110de6c1354c83770aae630ede9ac308d9f7b399ecfba23d923384'
        txBlockNumber:
          type: number
          nullable: true
          description: Block number
          example: 123456
        txTimestamp:
          format: date-time
          type: string
          nullable: true
          description: Timestamp
          example: '2021-01-01T00:00:00.000Z'
        txSenderAddress:
          type: string
          nullable: true
          description: Sender address
          example: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
        txGasUsed:
          type: number
          nullable: true
          description: Gas used
          example: 100000
        txTotalCost:
          type: string
          nullable: true
          description: Total cost
          example: '1000000000000000000'
        txTotalCostUsdFractions:
          type: number
          nullable: true
          description: Total cost in USD, 6 decimals of precision
          example: 1000000
        txIsSponsored:
          type: boolean
          nullable: true
          description: Is transaction sponsored
          example: true
        processedBy:
          nullable: true
          enum:
            - webhook
            - frontend
            - cron
            - manual
            - shout_webhook
          type: string
          description: Who processed the transaction (webhook, frontend, cron)
          example: webhook
        txRiskScore:
          type: number
          nullable: true
          description: Transaction risk score (1-100, higher is safer)
          example: 85
        txRiskSeverity:
          nullable: true
          enum:
            - CRITICAL_RISK
            - HIGH_RISK
            - MEDIUM_RISK
            - LOW_RISK
            - NO_RISK
          type: string
          description: Transaction risk severity label
          example: LOW_RISK
        txRiskProvider:
          type: string
          nullable: true
          description: Transaction risk provider identifier
          example: scorechain
        createdAt:
          format: date-time
          type: string
          description: Created at
      required:
        - paymentId
        - selectedQuote
        - settledToken
        - settledChain
        - settledAmountAsset
        - settledAmountUsd
        - txHash
        - txBlockNumber
        - txTimestamp
        - txSenderAddress
        - txGasUsed
        - txTotalCost
        - txTotalCostUsdFractions
        - txIsSponsored
        - processedBy
        - txRiskScore
        - txRiskSeverity
        - txRiskProvider
        - createdAt
    TokenDto:
      type: object
      properties:
        id:
          type: string
          description: Token ID
          example: 123e4567-e89b-12d3-a456-426614174000
        coingeckoApiId:
          type: string
          description: Coingecko API ID
          example: ethereum
        chain:
          description: Chain information
          allOf:
            - $ref: '#/components/schemas/ChainDto'
        symbol:
          type: string
          description: Token symbol
          example: USDC
        contractAddress:
          type: string
          description: Token contract address (lowercase)
          example: '0xa0b86a33e6441b8c4c8c0c0c0c0c0c0c0c0c0c0'
        decimals:
          type: number
          description: Token decimals
          example: 6
        type:
          enum:
            - stablecoin
            - volatile
          type: string
          description: Token type
          example: stablecoin
        assetType:
          enum:
            - native
            - erc20
          type: string
          description: Token asset type
          example: native
        status:
          enum:
            - active
            - deprecated
            - blocked
          type: string
          description: Token status
          example: active
        tokenPriceUsd:
          type: number
          nullable: true
          description: Token price in USD
          example: 1
      required:
        - id
        - coingeckoApiId
        - chain
        - symbol
        - contractAddress
        - decimals
        - type
        - assetType
        - status
        - tokenPriceUsd
    DepositAddressDto:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Deposit address ID
        paymentId:
          type: string
          nullable: true
        type:
          type: string
          enum:
            - EVM
        address:
          type: string
          description: Token contract address (lowercase)
          example: '0xa0b86a33e6441b8c4c8c0c0c0c0c0c0c0c0c0c0'
        createdAt:
          format: date-time
          type: string
      required:
        - id
        - type
        - address
        - createdAt
    ChainDto:
      type: object
      properties:
        chainId:
          type: string
          description: CAIP-2 chain id
          example: eip155:1
        name:
          type: string
          description: Chain name
          example: Ethereum
        nativeSymbol:
          type: string
          description: Native token symbol
          example: ETH
        nativeDecimals:
          type: number
          description: Native token decimals
          example: 18
        isEnabled:
          type: boolean
          description: Whether the chain is enabled
          example: true
        isTestnet:
          type: boolean
          description: Whether the chain is a testnet
          example: false
      required:
        - chainId
        - name
        - nativeSymbol
        - nativeDecimals
        - isEnabled
        - isTestnet
  securitySchemes:
    Secret Key:
      type: apiKey
      in: header
      name: x-spacepay-secret-key
      description: Secret key for authentication of external API.

````