openapi: 3.1.0
info:
  title: UPBOND Transfer API
  version: 1.3.0
  description: |
    Transfer API for corporate vaults (UPBOND MPC wallets). The vocabulary follows the
    Fireblocks-style transaction API (operation / assetId / source / destination / status).
    Scope: single ERC-20 (JPYC) transfers from a vault account to a one-time destination
    address, status lookup and polling.

    Signing modes are set per API key. Auto-signing mode (available): the caller wraps the
    vault owner's signing secret for UPBOND's signing environment in every request, and
    transfers within the per-transaction cap are signed without human approval. Approval mode
    (in preparation): the API key can only propose; the transaction waits in
    PENDING_AUTHORIZATION.

    Guides (Japanese): https://docs.upbond.io/transfer-api/
  contact:
    name: UPBOND
    url: https://docs.upbond.io/transfer-api/
servers:
  - url: https://{host}/v1
    description: Host names for STG and PROD are provided with the connection details.
    variables:
      host:
        default: api.example.upbond.io
security:
  - apiKey: []
    oauth2: []
tags:
  - name: transactions
  - name: signer
paths:
  /transactions:
    post:
      tags: [transactions]
      operationId: createTransaction
      summary: Create a transfer (one transaction per payout)
      description: |
        In auto-signing mode the request authenticates, checks the policy, unwraps the
        signing-secret envelope, signs and broadcasts before answering, so the response takes
        a few seconds (allow a 60–90 s client timeout) and `status` is usually `BROADCASTING`.
        `BLOCKED` means the per-transaction cap was exceeded (an UPBOND-side setting can route
        this to `PENDING_AUTHORIZATION` instead); `FAILED` means a pre-broadcast check or the
        signing failed (read `subStatus` with GET). A failed broadcast RPC is NOT terminal: the
        record stays `BROADCASTING` and is reconciled from chain. A missing receipt alone never
        fails it: the signed transaction stays valid until its nonce is spent and can still be
        mined later, so never re-create a `BROADCASTING` transaction under a new externalTxId
        (both could settle) — escalate to UPBOND if it stays there for more than 30 minutes.
        `txHash` is available from GET. If the chain cannot be read (balance / nonce) after
        the transaction was created but before signing, the transaction is terminal
        `FAILED` / `CONNECTIVITY_ERROR`: nothing was signed or broadcast, so re-create it
        later under a new externalTxId. If UPBOND itself fails (500)
        after the transaction was created, it may remain `PENDING_SIGNATURE`; a retry with the
        same Idempotency-Key returns that transaction's `{ id, status }` without signing again —
        escalate to UPBOND rather than creating a new externalTxId.

        Envelope problems (400 / 1401, 1402; 422 / 1410, 1411, 1414, 1415; 403 / 1412, 1413)
        and every other 4xx are decided before anything is persisted: the transaction is not
        created, `externalTxId` is not consumed, and the same `Idempotency-Key` can be re-sent.

        The envelope is bound to the request: its plaintext carries the SHA-256 of
        `assetId`, `source.id`, `destination.oneTimeAddress.address`, `amount`, `feeLevel`
        (MEDIUM when omitted), `externalTxId` and `note` ("" when omitted) (as sent,
        LF-joined) and an `issuedAt`
        within ±5 minutes of the
        server clock. An envelope captured from one request is refused on any other
        (422 / 1414), expires (422 / 1415), and cannot be used twice: a second use of the
        same envelope is a duplicate `externalTxId` (409 / 1201) and signs nothing.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TransactionRequest'
            examples:
              payout:
                value:
                  operation: TRANSFER
                  assetId: JPYC_AVALANCHE
                  source: { type: VAULT_ACCOUNT, id: "vault-account-id" }
                  destination:
                    type: ONE_TIME_ADDRESS
                    oneTimeAddress: { address: "0x1111111111111111111111111111111111111111" }
                  amount: "12345.00"
                  externalTxId: "refund-2026-000123"
                  note: "Refund #000123"
                  feeLevel: MEDIUM
                  signer: { keyId: "3", envelope: "BASE64_RSA_OAEP_CIPHERTEXT" }
      responses:
        '200':
          description: Accepted. Track the status by id or externalTxId.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateTransactionResponse'
              example: { id: "3f9c2b7e-8d0a-4c1e-9b5d-2a6f7e1c4d80", status: BROADCASTING }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '409': { $ref: '#/components/responses/Conflict' }
        '422': { $ref: '#/components/responses/Unprocessable' }
        '429': { $ref: '#/components/responses/TooManyRequests' }
    get:
      tags: [transactions]
      operationId: getTransactions
      summary: List transactions (polling)
      description: |
        Unknown query parameters are rejected with 400 / 1101. When more results exist the
        `next-page` response header carries the URL of the next page (it includes `cursor`);
        request that URL verbatim. Listed BROADCASTING/CONFIRMING records reflect the last
        background refresh; a single-record GET refreshes from chain (at most every 5 s).
      parameters:
        - name: after
          in: query
          description: Only transactions created at or after this time (Unix epoch milliseconds).
          schema: { type: integer, format: int64, minimum: 0 }
        - name: before
          in: query
          description: Only transactions created before this time (Unix epoch milliseconds).
          schema: { type: integer, format: int64, minimum: 0 }
        - name: status
          in: query
          description: Comma-separated status filter.
          schema: { type: string, example: "BROADCASTING,CONFIRMING" }
        - name: orderBy
          in: query
          schema: { type: string, enum: [createdAt, lastUpdated], default: createdAt }
        - name: sort
          in: query
          schema: { type: string, enum: [ASC, DESC], default: ASC }
        - name: limit
          in: query
          schema: { type: integer, minimum: 1, maximum: 500, default: 200 }
        - name: cursor
          in: query
          description: Opaque page position taken from the `next-page` header. Do not construct it.
          schema: { type: string }
      responses:
        '200':
          description: Transactions in the requested order.
          headers:
            next-page:
              description: URL of the next page. Absent on the last page.
              schema: { type: string }
          content:
            application/json:
              schema:
                type: array
                items: { $ref: '#/components/schemas/Transaction' }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/TooManyRequests' }
  /transactions/{txId}:
    get:
      tags: [transactions]
      operationId: getTransaction
      summary: Get one transaction by UPBOND id
      parameters:
        - name: txId
          in: path
          required: true
          schema: { type: string, format: uuid }
      responses:
        '200':
          description: The transaction.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Transaction' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/TooManyRequests' }
  /transactions/external_tx_id/{externalTxId}:
    get:
      tags: [transactions]
      operationId: getTransactionByExternalTxId
      summary: Get one transaction by the caller's externalTxId
      parameters:
        - name: externalTxId
          in: path
          required: true
          schema: { type: string, maxLength: 255 }
      responses:
        '200':
          description: The transaction.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Transaction' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/TooManyRequests' }
  /upbond/signer:
    get:
      tags: [signer]
      operationId: getSignerKey
      summary: Public key of the signing environment (auto-signing mode)
      description: |
        The RSA-4096 public key that wraps the signing secret. Cache until `expiresAt` and
        re-fetch at least daily. UPBOND's operating policy rotates the key about every 30 days
        and keeps the previous key usable for 7 days after a rotation; the contract enforced by
        the API is `expiresAt` plus this rule: a stale `keyId` is answered with 422 / 1410 —
        re-fetch and re-send the same request.
      responses:
        '200':
          description: Current signing-environment key.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/SignerKey' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/TooManyRequests' }
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key ID provided with the connection details (equals the OAuth client_id).
    oauth2:
      type: oauth2
      description: |
        Client credentials grant at the UPBOND authorization server (PROD https://auth.upbond.io,
        STG https://auth.stg.upbond.io). Client authentication is private_key_jwt (RFC 7523): a
        client assertion signed with the registered RSA key — iss = sub = API key ID,
        aud = the authorization server URL, jti unique, exp about iat + 60. Send only
        grant_type, client_assertion_type and client_assertion (client_id is optional and must
        equal iss; scope and resource are not used). The access token is OPAQUE and valid for
        5 minutes: cache it until expiry. The API validates it with the authorization server and
        requires its client_id to equal X-API-Key.
      flows:
        clientCredentials:
          tokenUrl: https://auth.upbond.io/oauth/token
          scopes: {}
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: |
        Any string up to 255 characters; use the externalTxId. For 24 hours the same key returns
        the original response. The same key with a different body is rejected with 409 / 1202;
        while the first request is still running, 409 / 1203. The body comparison excludes
        `signer`, and 4xx/5xx responses are never recorded against the key, so a corrected or
        re-enveloped request can be re-sent with the same key.
      schema: { type: string, maxLength: 255 }
  schemas:
    TransactionRequest:
      type: object
      additionalProperties: false
      required: [operation, assetId, source, destination, amount, externalTxId]
      properties:
        operation:
          type: string
          enum: [TRANSFER]
        assetId:
          type: string
          minLength: 1
          description: The asset of this environment, provided with the connection details (JPYC_AVALANCHE on PROD — Avalanche C-Chain, chainId 43114; JPYC_FUJI on STG — Avalanche Fuji, chainId 43113). Any other value is 422 / 1301.
        source:
          type: object
          additionalProperties: false
          required: [type, id]
          properties:
            type: { type: string, enum: [VAULT_ACCOUNT] }
            id: { type: string, minLength: 1, description: Vault account ID provided with the connection details. Must be the vault of the API key (else 403 / 1003). }
        destination:
          type: object
          additionalProperties: false
          required: [type, oneTimeAddress]
          properties:
            type: { type: string, enum: [ONE_TIME_ADDRESS] }
            oneTimeAddress:
              type: object
              additionalProperties: false
              required: [address]
              properties:
                address:
                  type: string
                  pattern: '^0x[0-9a-fA-F]{40}$'
        amount:
          type: string
          description: Decimal string in JPYC units (18 decimals), greater than zero. More than 18 fractional digits is 400 / 1103.
          pattern: '^[0-9]+(\.[0-9]{1,18})?$'
        externalTxId:
          type: string
          minLength: 1
          maxLength: 255
          description: Caller's id. Unique per vault account forever; a duplicate is 409 / 1201. No control characters (it is part of the envelope binding).
        note:
          type: string
          maxLength: 500
        feeLevel:
          type: string
          enum: [LOW, MEDIUM, HIGH]
          default: MEDIUM
        signer:
          type: object
          additionalProperties: false
          description: Required for an auto-signing API key (400 / 1401 if missing); must be omitted for an approval-mode key (400 / 1402).
          required: [keyId, envelope]
          properties:
            keyId:
              type: string
              minLength: 1
              description: keyId returned by GET /upbond/signer.
            envelope:
              type: string
              minLength: 1
              maxLength: 4096
              pattern: '^[A-Za-z0-9+/]+={0,2}$'
              description: |
                Standard base64 of the 73-byte BOUND plaintext encrypted with RSA-OAEP, SHA-256,
                MGF1-SHA-256, empty label, to publicKeyPem from GET /upbond/signer. Plaintext:
                byte 0 = 0x01 (version); bytes 1-32 = the raw 32-byte signing secret
                (base64-decoded); bytes 33-64 = SHA-256 of the canonical request, i.e. the UTF-8
                string `assetId\nsource.id\ndestination.oneTimeAddress.address\namount\nfeeLevel\nexternalTxId\nnote`
                with each value exactly as sent in this body (feeLevel = MEDIUM and note = ""
                when omitted; externalTxId must not contain control characters); bytes 65-72 =
                issuedAt, unsigned 64-bit big-endian Unix epoch milliseconds. Build a fresh
                envelope for every request right before sending it; a mismatching hash is
                422 / 1414, an issuedAt outside ±5 minutes is 422 / 1415, and the legacy
                32-byte unbound plaintext is 422 / 1411.
    CreateTransactionResponse:
      type: object
      required: [id, status]
      properties:
        id: { type: string, format: uuid }
        status: { $ref: '#/components/schemas/TransactionStatus' }
    TransactionStatus:
      type: string
      description: |
        Fireblocks-style enumeration. Emitted today: SUBMITTED, PENDING_AUTHORIZATION,
        PENDING_SIGNATURE, BROADCASTING, CONFIRMING, COMPLETED, BLOCKED, FAILED. Reserved for
        approval mode (not emitted today): REJECTED, CANCELLED. Terminal: COMPLETED, BLOCKED,
        REJECTED, CANCELLED, FAILED. Treat unknown values as "in progress".
      enum:
        - SUBMITTED
        - QUEUED
        - PENDING_AUTHORIZATION
        - PENDING_SIGNATURE
        - BROADCASTING
        - PENDING_3RD_PARTY_MANUAL_APPROVAL
        - PENDING_3RD_PARTY
        - CONFIRMING
        - PARTIALLY_COMPLETED
        - PENDING_AML_SCREENING
        - COMPLETED
        - CANCELLING
        - CANCELLED
        - REJECTED
        - BLOCKED
        - FAILED
        - PENDING_ENRICHMENT
    TransactionSubStatus:
      type: string
      description: |
        Reason detail, present only when there is one. CONFIRMED (COMPLETED); BLOCKED_BY_POLICY
        (BLOCKED: per-transaction cap or daily cumulative cap (JST calendar day) exceeded, or the
        destination is not on the vault owner's allowlist); INSUFFICIENT_FUNDS, INSUFFICIENT_FUNDS_FOR_FEE,
        REJECTED_BY_BLOCKCHAIN (a pre-signing chain read or gas estimation failed, reverted on chain, or the receipt lacks the
        expected transfer event), DROPPED_BY_BLOCKCHAIN
        (the broadcast transaction can no longer settle: no receipt 30 minutes after broadcasting
        AND another transaction of the vault spent its nonce and reached the required
        confirmations), SIGNING_FAILED, OWNER_REAUTH_REQUIRED
        (the vault owner's consent expired during signing; the owner must reconnect),
        CONNECTIVITY_ERROR (the chain could not be read before signing; nothing was signed or
        broadcast — re-create under a new externalTxId) — all FAILED;
        REJECTED_BY_USER (REJECTED) and TIMEOUT (FAILED) are reserved for approval mode and are
        not emitted today.
      enum:
        - CONFIRMED
        - BLOCKED_BY_POLICY
        - INSUFFICIENT_FUNDS
        - INSUFFICIENT_FUNDS_FOR_FEE
        - REJECTED_BY_BLOCKCHAIN
        - DROPPED_BY_BLOCKCHAIN
        - SIGNING_FAILED
        - OWNER_REAUTH_REQUIRED
        - CONNECTIVITY_ERROR
        - REJECTED_BY_USER
        - TIMEOUT
    Transaction:
      type: object
      required: [id, externalTxId, status, operation, assetId, source, destination, destinationAddress, amountInfo, feeLevel, numOfConfirmations, createdAt, lastUpdated, createdBy, signedBy]
      properties:
        id: { type: string, format: uuid }
        externalTxId: { type: string }
        status: { $ref: '#/components/schemas/TransactionStatus' }
        subStatus: { $ref: '#/components/schemas/TransactionSubStatus' }
        operation: { type: string, enum: [TRANSFER] }
        assetId: { type: string }
        source:
          type: object
          properties:
            type: { type: string, enum: [VAULT_ACCOUNT] }
            id: { type: string }
            name: { type: string }
        destination:
          type: object
          properties:
            type: { type: string, enum: [ONE_TIME_ADDRESS] }
        destinationAddress: { type: string }
        amountInfo:
          type: object
          properties:
            amount: { type: string }
            requestedAmount: { type: string }
            netAmount: { type: string }
        feeInfo:
          type: object
          description: Present once the receipt is known.
          properties:
            networkFee: { type: string, description: Native token amount actually paid. }
        feeLevel: { type: string, enum: [LOW, MEDIUM, HIGH] }
        txHash: { type: string, description: Present from BROADCASTING onward. }
        numOfConfirmations: { type: integer }
        blockInfo:
          type: object
          description: Present once the receipt is known.
          properties:
            blockHeight: { type: string }
            blockHash: { type: string }
        createdAt: { type: integer, format: int64, description: Unix epoch milliseconds. }
        lastUpdated: { type: integer, format: int64, description: Unix epoch milliseconds. }
        createdBy: { type: string, description: API key ID that created the transaction. }
        signedBy:
          type: array
          items: { type: string }
          description: '["api-factor"] once signed (BROADCASTING onward); [] before that.'
        rejectedBy: { type: string, description: Approval mode only. }
        note: { type: string }
    SignerKey:
      type: object
      required: [keyId, publicKeyPem, attestation, expiresAt]
      properties:
        keyId: { type: string }
        publicKeyPem: { type: string, description: RSA-4096 public key (PEM, SPKI). The private key lives in UPBOND's key management service and is not exportable. }
        attestation: { type: string, description: Empty string until an attested (isolated) signing environment is offered. }
        expiresAt: { type: integer, format: int64, description: Unix epoch milliseconds. Cache until then, re-fetch at least daily, and re-fetch on a 422 with code 1410. }
    Error:
      type: object
      required: [message, code]
      properties:
        message: { type: string, description: Developer-facing text; may change. Branch on code. }
        code:
          type: integer
          description: |
            Stable code. 400: 1101 unknown field or query parameter, 1102 invalid field,
            1103 invalid amount, 1104 malformed JSON, 1401 signer required, 1402 signer must be
            omitted. 401: 1001 missing X-API-Key, 1002 missing/invalid/expired token, 1003 token
            client_id differs from X-API-Key or unknown key. 403: 1003 source.id is not the key's
            vault, 1004 API key revoked, 1005 source IP not allowed, 1412 signing secret revoked,
            1413 signing secret not registered. 404: 1601. 409: 1201 externalTxId exists,
            1202 Idempotency-Key reused with a different body, 1203 Idempotency-Key in progress.
            422: 1301 unknown assetId, 1302 vault not ready, 1303 vault reconnect required,
            1304 the vault owner has not signed transfer limits for this key (or revoked them),
            1305 the owner's limits are expired or not yet valid,
            1410 stale signer keyId, 1411 envelope undecryptable or not the 73-byte bound
            plaintext, 1414 envelope bound to a different request, 1415 envelope issuedAt
            outside the accepted window. 429: 1501. 500: 5000.
  responses:
    BadRequest:
      description: Malformed request, unknown field, invalid amount, or signer present/absent for the wrong mode (codes 1101–1104, 1401, 1402).
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
          example: { message: "amount must be a decimal string with at most 18 fractional digits", code: 1103 }
    Unauthorized:
      description: Missing X-API-Key, invalid or expired access token, or client_id mismatch (codes 1001–1003).
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
          example: { message: "access token is not active", code: 1002 }
    Forbidden:
      description: source.id is not the key's vault (1003), API key revoked (1004), source IP not allowed (1005), signing secret revoked (1412) or not registered (1413).
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
          example: { message: "the signing secret has been revoked", code: 1412 }
    NotFound:
      description: No such transaction (1601).
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
          example: { message: "no such transaction", code: 1601 }
    Conflict:
      description: Duplicate externalTxId (1201), Idempotency-Key reused with a different body (1202), or the first request with this Idempotency-Key is still in progress (1203).
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
          example: { message: "externalTxId already exists", code: 1201 }
    Unprocessable:
      description: Unknown assetId (1301), vault not ready (1302), vault owner must reconnect (1303), no owner-signed transfer limits for the key — the owner sets them in the wallet, UPBOND cannot (1304), owner's limits expired or not yet valid (1305), stale signer keyId (1410), envelope undecryptable or not bound-format (1411), envelope bound to a different request (1414), envelope issuedAt outside ±5 minutes (1415).
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
          example: { message: "signer keyId is stale — re-fetch GET /v1/upbond/signer", code: 1410 }
    TooManyRequests:
      description: Rate limit exceeded (1501). Honour Retry-After (seconds). 10 requests/s with a burst of 20 per API key.
      headers:
        Retry-After:
          schema: { type: integer }
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
          example: { message: "rate limit exceeded", code: 1501 }
