Overview
The Subscription Events API allows external systems to send subscription-related events to AttributionX via a server-to-server REST API endpoint. This is designed for platforms that process subscriptions and need to track subscription status changes in the attribution system.
POST https://myxznsjxiabywzqxedih.supabase.co/functions/v1/subscription-events
Authentication is performed using an API key that must be included in the request body. The API key is a UUID string that identifies your registered host.
Content-Type: application/json
Field | Type | Required | Description |
| string (UUID) | Yes | Authentication key for your host |
| string | Yes | User's email address |
| string | Yes | Type of event: |
| string | Yes | Currency code (e.g., |
| string | No | Subscription ID from your platform |
| number | No | Payment amount (defaults to 0) |
| string | No | Subscription status (see allowed values below) |
payment_received - A payment has been received for the subscription
subscription_cancelled - The subscription has been cancelled
Status
Description
| Subscription currently in trial period |
| Active subscription with payment |
| Subscription has been cancelled |
Event is stored in the subscription_events table (event sourcing pattern)
Background worker processes the event and:
Finds the previously created subscription
Updates the subscription data in the subscriptions table
Updates the associated deal/transaction status
curl -X POST https://myxznsjxiabywzqxedih.supabase.co/functions/v1/subscription-events \
-H "Content-Type: application/json" \
-d '{
"apiKey": "123456789-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"eventType": "payment_received",
"status": "active",
"amount": 99.99,
"currency": "USD",
"subscriptionId": "sub_12345"
}'curl -X POST https://myxznsjxiabywzqxedih.supabase.co/functions/v1/subscription-events \
-H "Content-Type: application/json" \
-d '{
"apiKey": "123456789-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"eventType": "payment_received",
"status": "in_trial",
"amount": 0,
"currency": "USD",
"subscriptionId": "sub_12345"
}'curl -X POST https://myxznsjxiabywzqxedih.supabase.co/functions/v1/subscription-events \
-H "Content-Type: application/json" \
-d '{
"apiKey": "123456789-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"eventType": "subscription_cancelled",
"status": "cancelled",
"currency": "USD",
"subscriptionId": "sub_12345"
}'const response = await fetch('https://myxznsjxiabywzqxedih.supabase.co/functions/v1/subscription-events', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
apiKey: '123456789-e29b-41d4-a716-446655440000',
email: 'user@example.com',
eventType: 'payment_received',
status: 'active',
amount: 99.99,
currency: 'USD',
subscriptionId: 'sub_12345'
})
});
if (response.status === 201) {
console.log('Event recorded successfully');
}Code
Description
| Event successfully created |
| Bad request - missing required fields or invalid data |
| Authentication failed - invalid or missing API key |
| Server error |
Missing required field:
{
"error": "Missing required field: email"
}Invalid event type:
{
"error": "Invalid eventType. Allowed values: payment_received, subscription_cancelled"
}Invalid status:
{
"error": "Invalid status. Allowed values: future, in_trial, active, non_renewing, paused, cancelled, transferred"
}Authentication failed:
{
"error": "No apiKey received"
}{
"error": "Invalid apiKey received"
}{
"error": "The apiKey is not registered."
}