Starship Rewards API

Cancel Payout API

Cancel a pending payout and receive a refund to your wallet

Cancel Payout API

Cancel a payout that has not yet been completed. Cancelled payouts are refunded to your wallet.

Endpoint

POST /api/v1/payouts/:id/cancel

Authentication: API Key + Secret required

Request Headers

X-API-Key: sk_live_abc123def456
X-API-Secret: your-secret-here

Path Parameters

ParameterTypeDescription
idstringPayout ID to cancel (e.g., pyt_xyz789abc)

Cancellation Rules

A payout can only be cancelled when it's in certain states:

StatusCan Cancel?Notes
createdYesImmediately cancellable
queuedYesCan cancel before processing starts
processingMaybeDepends on provider - may already be submitted
settlingNoFunds already with beneficiary
action_requiredYesCan cancel while waiting for action
completedNoAlready delivered
failedNoAlready failed (refund automatic)
cancelledNoAlready cancelled
expiredNoAlready expired

Response

Success Response

Status Code: 200 OK

Returns the updated payout with cancelled status:

{
  "id": "pyt_xyz789abc",
  "reference_id": "PAY_2024_001",
  "status": "cancelled",
  "amount": 100.00,
  "currency": "USD",
  "fees": 1.50,
  "total_amount": 101.50,
  "beneficiary": {
    "email": "john.doe@example.com",
    "first_name": "John",
    "last_name": "Doe",
    "country": "US"
  },
  "description": "Bonus Payment",
  "created_at": "2024-01-15T10:30:00Z",
  "cancelled_at": "2024-01-15T10:32:00Z",
  "events": [
    {
      "event_type": "status_change",
      "from_status": null,
      "to_status": "created",
      "actor_type": "system",
      "message": "Payout created",
      "created_at": "2024-01-15T10:30:00Z"
    },
    {
      "event_type": "status_change",
      "from_status": "created",
      "to_status": "cancelled",
      "actor_type": "client",
      "message": "Payout cancelled by client",
      "created_at": "2024-01-15T10:32:00Z"
    }
  ]
}

Error Responses

400 Bad Request - Cannot Cancel

{
  "error": "BadRequest",
  "message": "payout cannot be cancelled in current status"
}

400 Bad Request - Already Completed

{
  "error": "BadRequest",
  "message": "payout has already been completed"
}

400 Bad Request - Missing ID

{
  "error": "BadRequest",
  "message": "Payout ID is required"
}

404 Not Found

{
  "error": "NotFound",
  "message": "Payout not found"
}

401 Unauthorized

{
  "error": "UnauthorizedAccess",
  "message": "Authentication required"
}

Examples

Basic Cancellation

curl -X POST "{{host}}/api/v1/payouts/pyt_xyz789abc/cancel" \
  -H "X-API-Key: sk_live_abc123def456" \
  -H "X-API-Secret: your-secret-here"

Safe Cancellation with Status Check

Batch Cancellation

User Confirmation Flow

Refund Process

When a payout is cancelled:

  1. Status Update - Payout status changes to cancelled
  2. Wallet Credit - The total amount (payout amount + fees) is refunded to the source wallet
  3. Event Logged - A cancellation event is added to the payout history
  4. Timestamp Set - The cancelled_at field is populated

Refund Timeline

  • Immediate: Cancellation of created or queued payouts
  • May take time: Cancellation of processing payouts (depends on provider)

Verify Refund

After cancellation, verify the refund in your wallet:

Error Handling

Handle Common Errors

Best Practices

  1. Check status first - Verify the payout is in a cancellable state before attempting
  2. Act quickly - Cancel as soon as possible; once processing starts, cancellation may fail
  3. Confirm with users - Always show a confirmation dialog for user-initiated cancellations
  4. Verify refunds - Check wallet balance or transaction history to confirm refund
  5. Log cancellations - Keep records of all cancellation attempts and outcomes

Use Cases

Duplicate Detection

Fraud Prevention