Receive a billing settlement notification
Chenvoya sends task.billing_settled after task.completed is delivered or abandoned and settlement reaches settled or settled_with_receivable.
- Any 2xx response confirms receipt; other answers and timeouts are retried on schedule.
- Signature, deduplication and retry rules are those of
task.completed. - Sent after
task.completedis delivered or abandoned and settlement is final. - A task still unsettled thirty days after completion gets no such event.
Headers
A convenience copy of the event ID. This header is not covered by the signature. After verifying the signature, deduplicate using event_id inside the signed body.
The notification signature contains t and v1. Check the timestamp as described in Callbacks, calculate HMAC-SHA256 over the original body bytes and compare in constant time.
Request body
The unique event ID inside the signed body. Deduplicate on this field after successful signature verification.
The notification object type, always event.
Whether this notification reports task completion or billing settlement.
task.completedThe task reached a final statetask.billing_settledThe task billing has been settledThe notification format version, currently the integer 1.
Event creation time in whole Unix seconds. Check it separately from each delivery attempt's signature timestamp.
The customer task snapshot saved when this event was created.
9 child fields
The platform Task ID belonging to your team.
The Request ID associated with task creation.
The billing correlation ID associated with task creation.
The public model ID used for this task.
dreamina-seedance-2-0-260128Seedance 2.0dreamina-seedance-2-0-fast-260128Seedance 2.0 Fastdreamina-seedance-2-0-mini-260615Seedance 2.0 MiniThe final task status: succeeded, failed or cancelled.
succeededSucceededfailedFailedcancelledCancelledResult delivery status when the event snapshot was saved.
pendingNot yet deliveredmaterializingPreparing the downloadavailableReady to downloadoutput_unavailableResult unavailableThe task error object, or null when there is no error.
3 child fields
A code your application can use to handle the error.
no_common_asset_routeAssets temporarily unavailableasset_not_readyA referenced asset is still processingasset_review_timeoutAsset review timed outroute_misconfiguredService configuration errorroute_temporarily_unavailableTemporarily unavailablegeneration_expiredGeneration expiredgeneration_failedGeneration failedinput_fetch_failedAn input could not be downloaded from its URLinput_url_not_allowedAn input URL is not allowedinput_too_largeAn input exceeds its size limitinput_unsupportedAn input format, dimensions or duration is unsupportedinput_rejectedAn input did not pass content reviewinput_preparation_failedThe inputs could not be prepared in timeinput_duration_exceededThe combined input duration exceeds the model limitA readable explanation of the error.
The billing settlement status when the event snapshot was saved.
reservedReservedpendingPendingreconciliation_requiredUnder reviewsettledSettledsettled_with_receivableSettled - amount dueThe final charge as a USD string with six decimal places, or null until determined.
Your response
The notification was received. Any 2xx response confirms delivery; other responses and timeouts cause scheduled retries.
Retry schedule
- after 10 seconds
- after 1 minute
- after 5 minutes
- then every hour
- for up to 7 days
Verify the signature
The full signature, deduplication and age rules are on Verify callback signatures.
import base64
import hashlib
import hmac
import time
def verify(signing_secret, header, body):
fields = {}
for item in header.split(","):
name, _, value = item.strip().partition("=")
fields[name] = value
t, v1 = fields.get("t", ""), fields.get("v1", "")
if not t.isdigit() or abs(time.time() - int(t)) > 300:
return False
key = base64.urlsafe_b64decode(signing_secret + "=" * (-len(signing_secret) % 4))
signed = b"chenvoya.v1." + t.encode() + b"." + body
expected = hmac.new(key, signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, v1)