跳到正文

API

本页内容

列表

按严格筛选条件列出转出,用游标分页向前翻页,核对目标网络,可靠地对账转账历史。

GET/v1/withdrawals

API 密钥: Payout

只返回已认证商户拥有、且在该 key 环境中创建的转出。结果按 created_at DESC、再按 withdrawal_id DESC 排序。

查询参数

参数 类型 默认值 说明
limit integer 20 每页大小,1 到 100
cursor string 上一个响应中的不透明 next_cursor
status string 精确的 snake_case 状态。重复该参数可匹配任一给定状态;不要发送逗号分隔的值
external_order_id string 精确的外部订单号,最长 200 字符
created_from Unix 秒 created_at 下限(含)
created_to Unix 秒 created_at 上限(不含)。必须晚于 created_from

未知参数、重复的标量参数、重复状态和大小写错误的枚举值会被拒绝,而不是被静默忽略。

示例

GET /v1/withdrawals?limit=20&status=created&status=pending_review HTTP/1.1
Host: api.paymos.io
Authorization: HMAC-SHA256 rk_live_…:…
X-Request-Timestamp: 1767225660

代码示例

每个标签页使用该语言的官方 SDK。签名、序列化、安全重试和类型化错误都由 SDK 处理。

API_KEY_ID="rk_live_xxxxxxxxxxxx"
API_SECRET="sk_live_xxxxxxxxxxxx"
QUERY="?status=created&limit=20"

TS=$(date +%s)
# No body: the hash slot is the EMPTY STRING, not sha256("").
SIGNATURE=$(printf '%s\n%s\n%s\n%s\n%s' "$TS" GET /v1/withdrawals "$QUERY" '' \
  | openssl dgst -sha256 -hmac "$API_SECRET" -binary | base64)

curl -sS "https://api.paymos.io/v1/withdrawals$QUERY" \
  -H "Authorization: HMAC-SHA256 $API_KEY_ID:$SIGNATURE" \
  -H "X-Request-Timestamp: $TS"
import { Paymos } from '@paymos/sdk';

const paymos = new Paymos({
  apiKey: process.env.PAYMOS_PAYOUT_KEY,
  apiSecret: process.env.PAYMOS_API_SECRET,
});

const page = await paymos.withdrawals.list({ status: ['created', 'pending_review'], limit: 20 });

for await (const withdrawal of paymos.withdrawals.iterate({ status: ['completed'] }, 10)) {
  console.log(withdrawal.withdrawalId);
}
import os

from paymos import Paymos

paymos = Paymos(
    api_key=os.environ["PAYMOS_PAYOUT_KEY"],
    api_secret=os.environ["PAYMOS_API_SECRET"],
)

page = paymos.withdrawals.list(status=["created", "pending_review"], limit=20)

for withdrawal in paymos.withdrawals.iterate(10, status=["completed"]):
    print(withdrawal["withdrawal_id"])
<?php
use Paymos\Client;
use Paymos\ClientConfig;

$paymos = new Client(new ClientConfig(
    getenv('PAYMOS_PAYOUT_KEY'),
    getenv('PAYMOS_API_SECRET')
));

$page = $paymos->withdrawals()->listPage(array(
    'status' => array('created', 'pending_review'),
    'limit' => 20,
));

foreach ($paymos->withdrawals()->iterate(array('status' => array('completed')), 10) as $withdrawal) {
    echo $withdrawal['withdrawal_id'] . PHP_EOL;
}
package main

import (
	"context"
	"fmt"
	"os"

	paymos "github.com/Paymos-labs/go-sdk/v2"
)

func main() {
	client, err := paymos.NewClient(os.Getenv("PAYMOS_PAYOUT_KEY"), os.Getenv("PAYMOS_API_SECRET"))
	if err != nil {
		panic(err)
	}

	page, err := client.Withdrawals.List(context.Background(), paymos.WithdrawalListParams{
		Status: []paymos.WithdrawalStatus{paymos.WithdrawalCreated, paymos.WithdrawalPendingReview},
		Limit:  20,
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(len(page.Items), page.NextCursor)

	iter := paymos.NewWithdrawalIterator(client.Withdrawals, paymos.WithdrawalListParams{
		Status: []paymos.WithdrawalStatus{paymos.WithdrawalCompleted},
	}, 10)
	for {
		withdrawal, ok, err := iter.Next(context.Background())
		if err != nil {
			panic(err)
		}
		if !ok {
			break
		}
		fmt.Println(withdrawal.WithdrawalID)
	}
}
using Paymos;

using var paymos = new PaymosClient(
    Environment.GetEnvironmentVariable("PAYMOS_PAYOUT_KEY")!,
    Environment.GetEnvironmentVariable("PAYMOS_API_SECRET")!);

var page = await paymos.Withdrawals.ListAsync(new WithdrawalListOptions(
    Status: [WithdrawalStatus.Created, WithdrawalStatus.PendingReview],
    Limit: 20));

await foreach (var withdrawal in paymos.Withdrawals.IterateAsync(
    new WithdrawalListOptions(Status: [WithdrawalStatus.Completed]), maxPages: 10))
{
    Console.WriteLine(withdrawal.WithdrawalId);
}
import io.paymos.Page;
import io.paymos.PaymosClient;
import io.paymos.Withdrawal;
import io.paymos.WithdrawalListOptions;
import io.paymos.WithdrawalStatus;

import java.util.List;

PaymosClient paymos = new PaymosClient(
    System.getenv("PAYMOS_PAYOUT_KEY"),
    System.getenv("PAYMOS_API_SECRET"));

Page<Withdrawal> page = paymos.withdrawals.list(WithdrawalListOptions.builder()
    .status(List.of(WithdrawalStatus.CREATED, WithdrawalStatus.PENDING_REVIEW))
    .limit(20)
    .build());

for (Withdrawal withdrawal : paymos.withdrawals.iterate(
        WithdrawalListOptions.builder().status(List.of(WithdrawalStatus.COMPLETED)).build(), 10)) {
    System.out.println(withdrawal.withdrawalId());
}
require 'paymos'

paymos = Paymos::Client.new(
  api_key: ENV.fetch('PAYMOS_PAYOUT_KEY'),
  api_secret: ENV.fetch('PAYMOS_API_SECRET')
)

page = paymos.withdrawals.list(status: ['created', 'pending_review'], limit: 20)

paymos.withdrawals.each(max_pages: 10, status: ['completed']) do |withdrawal|
  puts withdrawal.withdrawal_id
end
use paymos::{PaymosClient, WithdrawalListParams, WithdrawalStatus};

let paymos = PaymosClient::new(
    std::env::var("PAYMOS_PAYOUT_KEY")?,
    std::env::var("PAYMOS_API_SECRET")?,
)?;

let page = paymos
    .withdrawals()
    .list(&WithdrawalListParams {
        status: Some(vec![WithdrawalStatus::Created, WithdrawalStatus::PendingReview]),
        limit: Some(20),
        ..Default::default()
    })
    .await?;
println!("{} items, next_cursor={:?}", page.items.len(), page.next_cursor);

let mut pager = paymos.withdrawals().pager(
    WithdrawalListParams { status: Some(vec![WithdrawalStatus::Completed]), ..Default::default() },
    Some(10),
)?;
while let Some(withdrawal) = pager.next().await? {
    println!("{}", withdrawal.withdrawal_id);
}

响应 (200 OK)

{
  "items": [
    {
      "withdrawal_id": "wdr_6Qm2fK8xR4vN7cT1bY9dL5",
      "external_order_id": "payout-1042",
      "status": "completed",
      "is_final": true,
      "is_test": false,
      "amount": "100.00",
      "fee": "1.00",
      "currency": "USDT",
      "network": "TRC20",
      "destination_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
      "created_at": 1767225600,
      "completed_at": 1767226120
    }
  ],
  "next_cursor": null
}

列表项刻意保持精简,不暴露交易哈希或执行内部细节。完整资源用 获取转出。响应携带 Cache-Control: private, no-store

分页规则

  • 没有页码,也没有 total_count:跟随 next_cursor 直到它为 null
  • 游标是不透明的,带防篡改保护,24 小时后过期。
  • 游标绑定转出资源和精确的筛选条件。翻页之间保持筛选条件不变;limit 可以改。
  • 缺失或终止的游标表示为 next_cursor: null
  • 如果游标无效、过期、用在其他资源上或搭配了不同的筛选条件,请不带游标重新开始。

错误

Payment(pk_)key 会被拒绝并返回 403 payout_key_required。无效筛选条件返回字段级 400;无效游标返回 400 pagination_cursor_invalid。见 错误码