Docs/API REFERENCE/Attribute Payment

Attribute Payment

POST

Attribute Payment

The attribute payment endpoint creates a payment event from your server and attaches it to an existing TrackFox visitor session. Use it when payment or checkout completion happens outside the browser.

How It Works

Send the website ID, visitor ID, session ID, revenue amount, and customer email from your backend. TrackFox looks up the matching visitor event, copies its attribution context, and creates a payment event with revenue data.

The endpoint authenticates the request using the API token for the website_id in the JSON body.

Use Case

Use this endpoint for Stripe, Paddle, Lemon Squeezy, PayPal, or custom checkout flows where the final payment confirmation is only available server-side.

Endpoint

POST https://trackfox.app/api/v1/attribute-payment

Authentication

This endpoint requires authentication using a Bearer token.

Authorization: Bearer tf_your_api_token_here

Request Body

Send a JSON object with the following fields.

Field Type Required Description
session_id string Yes TrackFox session ID for the visitor session
visitor_id string Yes TrackFox visitor ID
website_id string Yes The unique identifier of your website
revenue number Yes Payment amount in cents. Must be a positive integer
email string Yes Customer email address

Response Format

On success, the API returns:

{
  "message": "Payment event attributed successfully."
}

Error Responses

400 Bad Request

The request is missing a required field, the email is invalid, or revenue is not a positive integer in cents.

401 Unauthorized

The Authorization header is missing, malformed, or contains an invalid API token.

404 Not Found

No matching event was found for the supplied session_id, visitor_id, and website_id.

500 Internal Server Error

An unexpected server error occurred.

Example Usage

cURL Request

curl "https://trackfox.app/api/v1/attribute-payment" \
  -X POST \
  -H "Authorization: Bearer tf_your_api_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "tf_session_id",
    "visitor_id": "tf_visitor_id",
    "website_id": "your_website_id",
    "revenue": 9900,
    "email": "customer@example.com"
  }'

JavaScript Fetch

const response = await fetch("https://trackfox.app/api/v1/attribute-payment", {
  method: "POST",
  headers: {
    Authorization: "Bearer tf_your_api_token_here",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    session_id: "tf_session_id",
    visitor_id: "tf_visitor_id",
    website_id: "your_website_id",
    revenue: 9900,
    email: "customer@example.com",
  }),
});

const data = await response.json();
console.log(data.message);

Next Steps

Need help? Contact us for assistance.

Suggest features? We'd love your feedback