Create and verify payment links with the Stax API, read the returned URL, and configure optional merchant payment URLs.
Generate a payment link with the Stax API to accept a fixed amount or let your customer enter an amount.
This reference is for developers integrating POST /query/payment-links, not for creating links in the Dashboard. A successful request returns HTTP 201 and a payment link URL in body.tinyurl.
Create links with predetermined payment amounts for specific products or services.
Allow customers to input their own payment amount for donations or custom services.
Add customer details, purpose, and other contextual information to your payment links.
Use the Returned Payment Link
- Send your create-payment-link request using the endpoint fields documented on this page.
- Check for HTTP
201before using the response. - Read
body.tinyurlfrom the JSON response and open that URL to verify the payment page before sharing it with your customer.
Use the returned URL rather than manually assembling a link with a placeholder token. The following Python 3 example extracts the URL from the endpoint's documented success response. It runs locally without credentials and does not create a payment link or process a payment.
import json
# This sample comes from the documented API response, not a Dashboard ID.
response_json = '''{
"status": 201,
"message": "Payment Link created",
"body": {
"link_meta": {
"paymentLinkId": "11eda15bbc337c209a1b615ba5112be7"
},
"merchant_id": "merchant1",
"common_name": "sameple link",
"id": "11eda15bbc337c209a1b615ba5112be7",
"tinyurl": "https://paymnt.io/nMeuJc"
}
}'''
try:
response = json.loads(response_json)
if not isinstance(response, dict):
raise ValueError("Expected a JSON object.")
if response.get("status") != 201:
raise ValueError(f"Payment link creation failed: {response}")
body = response.get("body")
if not isinstance(body, dict):
raise ValueError("The response has no payment link body.")
payment_url = body.get("tinyurl")
if not isinstance(payment_url, str) or not payment_url.startswith("https://"):
raise ValueError("The response has no valid HTTPS payment link URL.")
print(payment_url)
except (ValueError, TypeError) as error:
raise SystemExit(f"Cannot read payment link: {error}") from errorExpected output:
https://paymnt.io/nMeuJcThe sample URL illustrates the response format; use the URL from your own successful API response when sharing a payment link. Invalid JSON, unsuccessful responses, and missing or invalid URLs stop the example with an explanatory error instead of printing a link.
Optional: Construct a Merchant Payment URL
If you construct a merchant payment URL instead of using body.tinyurl, choose the domain that matches your merchant configuration.
For merchants without a custom domain, append your actual merchant_website_payments_token value to https://app.staxpayments.com/#/pay/ without spaces or a plus sign.
This endpoint's documented response does not include that token or explain where to retrieve it in the Dashboard. Use the returned body.tinyurl if you do not already have the token; do not substitute a payment link ID or merchant ID.
For partners with a configured custom domain, replace the hostname app.staxpayments.com in the standard merchant payment URL with your configured hostname. Keep the /#/pay/ path and your actual merchant website payments token.
Verify your domain configuration and open the resulting payment page before sharing the URL. An incorrect domain configuration can prevent customers from opening the link.
Optional: Configure Payment Links
Metadata Settings
Custom Metadata: Add optional metadata to personalize links for specific use cases, including:
- Customer identification details
- Payment purpose or description
- Internal tracking references
- Campaign or source attribution
Expiration Controls
Expiration Settings: Configure link expiration to maintain security and control:
- Set specific expiration dates to prevent misuse
- Choose expiration periods that match your business needs
- Consider customer convenience when setting expiration periods
Security Validation
Request Validation: Always validate required attributes in your requests:
- Verify all mandatory fields are present
- Check data formats and constraints
- Implement proper error handling for failed validations
API Response Codes
Response Structure
| Code | Response | Reason |
|---|---|---|
| 201 | Created | The payment link was successfully created. |
| 400 | Bad Request | Missing required parameters. |
| 401 | Unauthorized | Authentication failed. |
| 500 | Internal Server Error | Unexpected server error occurred. |
Recommended: Test and Secure Your Integration
Validate required request fields before sending requests. The checks below are recommendations for testing and operating your integration; they are not guarantees of security or legal compliance.
Optional: Track Payment Context
Use metadata fields to track payment context, add customer-specific details, or integrate with your internal systems.
Security validation and expiration controls support your compliance efforts; they do not establish legal compliance. Consult your legal team regarding specific requirements.
