Skip to Content

Create Payment

POST/payments/new

Description

Create a new payment request. This endpoint initiates a transaction by generating a unique payment request. Once created, it returns essential details such as a payment ID and the URL for the customer to make the payment.

Headers

HeaderDescriptionRequired
Content-Typeapplication/jsonyes
x-api-keyYour API keyyes

Request Body

Required Fields

NameTypeDescription
totalAmountnumberAmount to be paid.
fiatCurrencystringCurrency in ISO code. Only UYU, USD, EUR, and ARS accepted.

Optional Fields

NameTypeDescription
customUsdPriceRatenumber | nullRequired if currency is UYU or ARS. Must be null for USD and EUR.
externalReferenceIdstring | nullReference ID for external integration.
posIdstring | nullUse only with Physical integration, if PoS is configured.
callbackUrlstring | nullUse only with Online integration. Redirect URL after payment.
itemsarray | nullArray of item objects for invoice details. Maximum 20 items.
expiresInnumber | nullPayment expiration time in minutes. Must be between 1 and 1440 (24 hours).
invoiceCreatedAtstring | nullUTC timestamp in ISO 8601 format: YYYY-MM-DDTHH:mm:ssZ
invoiceDiscountstring | nullDiscount applied at invoice level.
externalClientIdstring | nullExternal identifier for the client.
customerEmailstring | nullCustomer's email address.

Items Schema

Each item in the items array can contain:

NameTypeDescriptionRequired
namestringItem nameyes
quantitynumberQuantity of the item. Must be at least 1.yes
unitPricenumberPrice per unit. Must be at least 0.01.yes
descriptionstringItem descriptionno
discountnumberDiscount applied to this item. Note: If provided, subtotal is required.no
subtotalnumberSubtotal for this item. Required when discount is provided.no
externalProductIdstringExternal identifier for the productno
⚠️

Calculation Validation: Grateful stores all item details and invoice information for display purposes only. The system does not validate mathematical relationships between item-level or invoice-level calculations. The payment will always charge the exact totalAmount specified, regardless of item details.

Example Request

const response = await fetch('https://merchant.grateful.me/api/payments/new', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': '<your-api-key>',
  },
  body: JSON.stringify({
    totalAmount: 50.0,
    fiatCurrency: 'USD',
    externalReferenceId: 'order-12345',
    customerEmail: '[email protected]',
    callbackUrl: 'https://yoursite.com/payment-complete',
    items: [
      {
        name: 'Coffee',
        quantity: 2,
        unitPrice: 15.0,
      },
      {
        name: 'Croissant',
        description: 'Freshly baked',
        quantity: 1,
        unitPrice: 20.0,
        externalProductId: 'croissant-001',
      },
    ],
  }),
});

Response

SUCCESSFUL PAYMENT CREATION (200)
{
  "id": "e0611550-0935-40f1-9cad-63096476207d",
  "recipient": "0x549A9021661a85B6BC51c07B3A451135848d0048",
  "fiatAmount": 50.0,
  "fiatCurrency": "USD",
  "customUsdPriceRate": null,
  "tokenAmount": null,
  "enabledTokens": {
    "DAI": [42161, 8453, 137, 10],
    "USDC": [56, 8453, 42161, 137, 10],
    "USDT": [137, 42161, 56, 8453]
  },
  "selectedToken": null,
  "merchantId": "2aab0e4a-cb50-44ac-88ef-8a5b79fd7d75",
  "selectedChainId": null,
  "depositAddress": null,
  "senderAddress": null,
  "expiresAt": "2025-09-09T03:57:43.053Z",
  "status": "AwaitingConfiguration",
  "error": null,
  "contractPaymentId": "298251156122803456481887845141481660541",
  "integrationId": 63,
  "createdAt": "2025-09-08T19:37:43.053Z",
  "updatedAt": "2025-09-08T19:37:43.054Z",
  "processing": false,
  "posId": null,
  "isYieldingFunds": false,
  "gratefulFee": null,
  "callbackUrl": "https://yoursite.com/payment-complete",
  "metadata": {
    "externalReferenceId": "order-12345",
    "externalClientId": null,
    "paymentItems": [
      {
        "id": "ab2813db-97b5-46b2-992b-3758366ee982",
        "name": "Coffee",
        "quantity": 2,
        "unitPrice": 15.0
      },
      {
        "id": "1e29d7f7-2f47-404c-8ddc-3d3650958e35",
        "name": "Croissant",
        "description": "Freshly baked",
        "quantity": 1,
        "unitPrice": 20.0,
        "externalProductId": "croissant-001"
      }
    ],
    "customerEmail": "[email protected]"
  },
  "merchant": {
    "id": "2aab0e4a-cb50-44ac-88ef-8a5b79fd7d75",
    "name": "Your Store",
    "avatarUrl": "https://example.com/avatar.png",
    "username": "yourstore",
    "country": "United States"
  },
  "url": "https://grateful.me/p/e0611550-0935-40f1-9cad-63096476207d",
  "fiatAmountInUSD": 50.0
}

Responses

StatusDescription
200Success
400Bad Request - Invalid parameters

Start building

XO

Request Demo

Schedule a call with our team

Select a product
Arrow right

Start building
Grateful

Contact Us

We're here to help