After an asset is sold
This guide explains how to register a completed sale in HL Connect and track fulfillment until the asset becomes available.
The Purchase API is asynchronous by design. After a sale happens on your side, you notify HL Connect about the purchase and then track its processing status until completion.
Overview
Once an asset is sold on the vendor side:
- The vendor registers the purchase in HL Connect
- HL Connect creates an order and starts fulfillment
- The vendor polls the order status
- After completion, the asset becomes available
- If required, access can later be revoked by the vendor
This flow allows HL Connect to safely handle retries, delays, and external business events without blocking your system.
Step 1 — Validate the purchase
Before you process the payment on your side, it's highly recommended to validate the purchase. This ensures that the asset is available for sale and that the customer is eligible to purchase it (e.g., they are not in a restricted region).
If validation is successful, you will receive a validation token and an
expiration timestamp (exp_date).
This token is short-lived, one-time use, and must be passed to the registration endpoint in the next step.
Step 2 — Register the purchase
After the asset is sold (and payment is confirmed), register the purchase in HL Connect
using the token obtained in Step 1.
This request notifies HL Connect that an asset was sold and that fulfillment should begin.
What happens
- The validation token is verified (must not be expired or used)
- Request parameters are validated
- A new vendor order is created
- Fulfillment starts asynchronously
- The validation token is invalidated (cannot be reused)
- The request returns immediately
If an order already exists for the same parameters, the API returns a
409 Conflict response.
Step 3 — Track order processing
Fulfillment does not complete immediately. Use the order info endpoint to check the current status.
Possible responses
| Status | Meaning |
|---|---|
202 |
Order is still processing |
200 |
Order completed, assets are available |
502 |
Fulfillment failed |
404 |
Order not found |
Your integration is expected to poll this endpoint until the order reaches a terminal state.
Order lifecycle
| Status | Description |
|---|---|
PROCESSING |
Fulfillment is in progress |
COMPLETED |
Order fulfilled, access granted |
FAILED |
Fulfillment failed |
CANCELED |
Access revoked by the vendor |
Status values are stable and safe to persist in your system.
Step 4 — Access the asset
Once an order reaches COMPLETED, assets become accessible using secure URLs.
Download the asset
Returns a secure URL for downloading the asset file.
View the asset online
Returns a secure URL for online viewing (for example, a sheet music viewer).
Vendor-initiated cancellation
If access to an asset must be revoked due to a business event on the vendor side, the vendor can cancel a specific order line item.
Cancellation updates the order state and revokes access to the asset.
Common integration pattern
sequenceDiagram
participant Customer
participant Vendor
participant HL as HL Connect
Customer->>Vendor: Wants to buy asset
Vendor->>HL: POST /purchase/validate-purchase-before-payment
HL-->>Vendor: 200 OK (token, exp_date)
Vendor->>Customer: Proceed to payment
Customer->>Vendor: Payment successful
Vendor->>HL: POST /purchase/register (token)
HL-->>Vendor: 201 Created
loop Until completed
Vendor->>HL: GET /purchase/info
HL-->>Vendor: PROCESSING
end
HL-->>Vendor: COMPLETED
Error handling
The Purchase API uses standard HTTP status codes:
400— bad request (e.g., validation failed, region not allowed)401— missing or invalid access token404— asset or order not found409— duplicate purchase registration422— request validation failed (e.g., expired or invalid validation token)5xx— fulfillment or internal errors
Errors are returned in a structured JSON format and are safe to log or display.
Summary
- Validate the purchase before payment using
/purchase/validate-purchase-before-payment - Register each completed sale using
/purchase/registerwith the validation token - Treat fulfillment as asynchronous
- Poll
/purchase/infountil a terminal state is reached - Grant access only after
COMPLETED - Revoke access using
/purchase/cancelwhen needed