How to use this API?

Overview

This guide provides a step-by-step walkthrough for integrating with Lia’s checkout system. By following this process, you will create products, configure offers with payment options, and share checkout links with your customers.

The integration follows this workflow:

  1. List available kinds and shifts
  2. Create a product
  3. Create an offer with payment configurations
  4. Share the offer URL with your customers
  5. Set up webhooks to receive event notifications (optional)

Prerequisites

Before you begin, ensure you have:

  • A valid API token for authentication
  • Access to the external API endpoints (sandbox or production)
  • The base URL for your environment:
    • Sandbox: https://external-api-sandbox.lia.com.br
    • Production: https://external-api.lia.com.br

All requests must include an Authorization header:

Authorization: Bearer YOUR_API_TOKEN

Step 1: List Available Kinds

Kinds represent the type or category of your product (e.g., Course, Event, Mentorship, eBook, Template).

Request

curl --location 'https://external-api-sandbox.lia.com.br/external_api/v1/kinds' \
--header 'Authorization: Bearer YOUR_API_TOKEN'

Response

[
  {
    "id": "95c7a40c-fe12-4459-bc53-7a16cf6b2493",
    "name": "Curso"
  },
  {
    "id": "3dc875cd-a61f-4e08-963d-2b6fa9686f86",
    "name": "Evento"
  },
  {
    "id": "b84e388d-9a38-4111-a574-c4e6aa07a6a4",
    "name": "Mentoria"
  },
  {
    "id": "8a145abf-9463-4088-bbd0-978c3a1312cf",
    "name": "eBook"
  },
  {
    "id": "34f575df-d133-41fe-b981-33b02bc09a4b",
    "name": "Arquivo/Template"
  }
]

Action: Select the id of the kind that best fits your product. For this example, we’ll use:

  • kind_id: 95c7a40c-fe12-4459-bc53-7a16cf6b2493 (Curso)

Step 2: List Available Shifts

Shifts represent the schedule or timing of your product (e.g., Morning, Afternoon, Evening, Online).

Request

curl --location 'https://external-api-sandbox.lia.com.br/external_api/v1/shifts' \
--header 'Authorization: Bearer YOUR_API_TOKEN'

Response

[
  {
    "id": "7b062161-db67-4ae4-b591-1ee242dcebb3",
    "name": "Online"
  },
  {
    "id": "ffffcf81-fada-5b2e-bec3-ecbbac9fea04",
    "name": "Matutino"
  },
  {
    "id": "a6d32eff-195d-5f8b-8467-27f3d34dd847",
    "name": "Vespertino"
  }
]

Action: Select the id of the shift that best fits your product. For this example, we’ll use:

  • shift_id: 7b062161-db67-4ae4-b591-1ee242dcebb3 (Online)

Step 3: Create a Product

A product represents what you are selling. You must specify the full price, access period, and other details.

Access Period Options

  • lifetime: Product access never expires
  • days: Access expires after a specified number of days (requires duration_in_days)
  • period: Access is available within a specific date range (requires start_date and end_date)
  • undefined_period: Access period is not yet defined

Request

curl --location 'https://external-api-sandbox.lia.com.br/external_api/v1/products' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--data '{
  "name": "Complete Web Development Course",
  "full_amount_cents": 299700,
  "kind_id": "95c7a40c-fe12-4459-bc53-7a16cf6b2493",
  "shift_id": "7b062161-db67-4ae4-b591-1ee242dcebb3",
  "access_period": "days",
  "duration_in_days": 365,
  "description": "Learn full-stack web development with React, Node.js, and PostgreSQL. Includes 100+ hours of video content, projects, and lifetime support.",
  "meta_pixel_code": "1234567890",
  "google_pixel_code": "GTM-XXXXXXX",
  "metadata": {
    "course_level": "intermediate",
    "language": "pt-BR",
    "instructor": "John Doe"
  }
}'

Request Parameters

ParameterDescriptionRequiredType
nameName of your productYesString
full_amount_centsFull price in cents (between 500 and 500000000)YesInteger
kind_idKind unique identifier from Step 1YesString
shift_idShift unique identifier from Step 2YesString
access_periodAccess period type: days, period, lifetime, or undefined_periodYesString
duration_in_daysNumber of days of access (required if access_period is days)ConditionalInteger
duration_in_hoursTotal duration in hoursNoInteger
start_dateStart date in ISO8601 format (required if access_period is period)ConditionalString
end_dateEnd date in ISO8601 format (required if access_period is period)ConditionalString
descriptionProduct descriptionNoString
meta_pixel_codeMeta Pixel ID for trackingNoString
google_pixel_codeGoogle Tag Manager ID for trackingNoString
metadataAdditional data for your integrationNoObject
bannerProduct image (PNG, JPEG, WEBP, max 500kB)NoFile

Response

{
  "id": "ce375417-b11a-527a-85f1-30d1202cd5c3",
  "name": "Complete Web Development Course",
  "full_amount_cents": 299700,
  "full_amount_currency": "BRL",
  "created_at": "2024-03-15T14:30:07.673-03:00",
  "description": "Learn full-stack web development with React, Node.js, and PostgreSQL. Includes 100+ hours of video content, projects, and lifetime support.",
  "availability": "enabled",
  "duration_in_hours": null,
  "access_period": "days",
  "duration_in_days": 365,
  "start_date": null,
  "end_date": null,
  "meta_pixel_code": "1234567890",
  "google_pixel_code": "GTM-XXXXXXX",
  "banner_url": null,
  "updated_at": "2024-03-15T14:30:07.673-03:00",
  "metadata": {
    "course_level": "intermediate",
    "language": "pt-BR",
    "instructor": "John Doe"
  },
  "company_id": "6883d1f9-0cf0-5167-a6bd-fc57b08454a5",
  "formatted_access_period": "365 dias",
  "kind": {
    "id": "95c7a40c-fe12-4459-bc53-7a16cf6b2493",
    "name": "Curso"
  },
  "shift": {
    "id": "7b062161-db67-4ae4-b591-1ee242dcebb3",
    "name": "Online"
  },
  "offers": []
}

Action: Save the product id from the response. For this example:

  • product_id: ce375417-b11a-527a-85f1-30d1202cd5c3

Step 4: Create an Offer with Payment Configurations

An offer defines how customers can purchase your product. It includes the price and available payment methods.

Understanding Payment Configurations

There are two main payment types:

1. Upfront Payment

Customer pays the full amount immediately (in one or multiple installments).

Example configurations:

  • PIX (instant payment, single installment)
  • Credit Card (up to X installments with interest)

2. Financed Payment

Customer makes a down payment, then pays the remaining balance in installments over time.

Financed types:

  • bolepix: Down payment via PIX or credit card; installments via boleto or PIX
  • card: Down payment and installments via credit card only

Request

curl --location 'https://external-api-sandbox.lia.com.br/external_api/v1/offers' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--data '{
  "offer": {
    "product_id": "ce375417-b11a-527a-85f1-30d1202cd5c3",
    "name": "Standard Payment Plan",
    "amount_cents": 299700
  },
  "payment_configurations": [
    {
      "payment_type": "upfront",
      "payment_methods": ["pix"],
      "expires_in_hours": 72
    },
    {
      "payment_type": "upfront",
      "payment_methods": ["credit_card"],
      "expires_in_hours": 24,
      "interest_rate": 0.0149,
      "max_installments": 12
    },
    {
      "payment_type": "financed",
      "financed_type": "bolepix",
      "allowed_down_payment_methods": ["pix", "credit_card"],
      "payment_methods": ["pix", "boleto"],
      "expires_in_hours": 48,
      "interest_rate": 0.0399,
      "max_installments": 24,
      "down_payment_type": "percentage",
      "down_payment_value": 0.2,
      "down_payment_interest_rate": 0.0,
      "fee_embedded_in_down_payment": true
    }
  ]
}'

Payment Configuration Parameters

ParameterDescriptionRequiredType
payment_typePayment type: upfront or financedYesString
payment_methodsArray of payment methods: pix, boleto, credit_card. Required for upfront; for financed it defaults to all threeConditionalArray
expires_in_hoursHours until payment expires (maximum 240). Defaults to the company defaultNoInteger
interest_rateMonthly interest rate (e.g., 0.0149 = 1.49% per month)ConditionalFloat
max_installmentsMaximum number of installmentsConditionalInteger
financed_typeType of financing: bolepix or card (required if payment_type is financed)ConditionalString
allowed_down_payment_methodsArray of methods for down payment (required if payment_type is financed)ConditionalArray
down_payment_typeDown payment calculation: percentage or absolute. When not sent, the company default down payment is usedNoString
down_payment_valueDown payment amount: a fraction for percentage (e.g. 0.2 for 20%) or cents for absoluteNoFloat/Integer
down_payment_interest_rateInterest rate for down payment installmentsNoFloat
max_down_payment_installmentsMaximum number of credit card installments for the down paymentNoInteger
fee_embedded_in_down_paymentWhether registration fee is included in down paymentNoBoolean

Response

{
  "id": "c013d81e-57e9-519e-8f3b-8d161568dbca",
  "name": "Standard Payment Plan",
  "amount_cents": 299700,
  "amount_currency": "BRL",
  "availability": "enabled",
  "created_at": "2024-03-15T15:45:23.456-03:00",
  "updated_at": "2024-03-15T15:45:23.456-03:00",
  "url": "https://pague-sandbox.lia.com.br/lia/oferta?offer_id=c013d81e-57e9-519e-8f3b-8d161568dbca",
  "smart_payment_enabled": false,
  "checkout_type": "default",
  "expires_at": null,
  "seats": null,
  "payment_configurations": [
    {
      "id": "1aaee0e3-eb78-5984-83bc-8b41fa289755",
      "payment_type": "upfront",
      "payment_methods": [
        "pix"
      ],
      "expires_in": 72,
      "financed_type": null,
      "interest_rate": "0.0",
      "max_installments": 1,
      "min_installment_amount_cents": 0,
      "allowed_down_payment_methods": [],
      "down_payment_type": null,
      "down_payment_value": 0.0,
      "down_payment_interest_rate": null,
      "max_down_payment_installments": null,
      "registration_fee": 0.0,
      "take_rate_type": "absolute",
      "take_rate_value": "297.0",
      "availability": "enabled",
      "fee_embedded_in_down_payment": false,
      "max_amount_cents": null
    },
    {
      "id": "1aaee0e3-eb78-5984-83bc-8b41fa289755",
      "payment_type": "upfront",
      "payment_methods": [
        "credit_card"
      ],
      "expires_in": 72,
      "financed_type": null,
      "interest_rate": "0.0149",
      "max_installments": 12,
      "min_installment_amount_cents": 1000,
      "allowed_down_payment_methods": [],
      "down_payment_type": null,
      "down_payment_value": 0.0,
      "down_payment_interest_rate": null,
      "max_down_payment_installments": null,
      "registration_fee": 0.0,
      "take_rate_type": "percentage",
      "take_rate_value": "0.0297",
      "availability": "enabled",
      "fee_embedded_in_down_payment": false,
      "max_amount_cents": null
    },
    {
      "id": "eff875a9-ac27-54a1-b1cd-57d89b336cb0",
      "payment_type": "financed",
      "payment_methods": [
        "pix",
        "boleto"
      ],
      "expires_in": 48,
      "financed_type": "bolepix",
      "interest_rate": 0.0399,
      "max_installments": 24,
      "min_installment_amount_cents": 5000,
      "allowed_down_payment_methods": [
        "pix",
        "credit_card"
      ],
      "down_payment_type": "percentage",
      "down_payment_value": 0.2,
      "down_payment_interest_rate": 0.0,
      "max_down_payment_installments": 4,
      "registration_fee": 0.0297,
      "take_rate_type": "percentage",
      "take_rate_value": 0.08,
      "availability": "enabled",
      "fee_embedded_in_down_payment": true,
      "max_amount_cents": null
    }
  ],
  "product": {
    "id": "ce375417-b11a-527a-85f1-30d1202cd5c3",
    "name": "Complete Web Development Course",
    "full_amount_cents": 299700,
    "full_amount_currency": "BRL",
    "created_at": "2024-03-15T14:30:07.673-03:00",
    "description": "Learn full-stack web development with React, Node.js, and PostgreSQL. Includes 100+ hours of video content, projects, and lifetime support.",
    "availability": "enabled",
    "duration_in_hours": null,
    "access_period": "days",
    "duration_in_days": 365,
    "start_date": null,
    "end_date": null,
    "meta_pixel_code": "1234567890",
    "google_pixel_code": "GTM-XXXXXXX",
    "banner_url": null,
    "updated_at": "2024-03-15T14:30:07.673-03:00",
    "metadata": {
      "course_level": "intermediate",
      "language": "pt-BR",
      "instructor": "John Doe"
    },
    "company_id": "6883d1f9-0cf0-5167-a6bd-fc57b08454a5",
    "formatted_access_period": "365 dias",
    "kind": {
      "id": "95c7a40c-fe12-4459-bc53-7a16cf6b2493",
      "name": "Curso"
    },
    "shift": {
      "id": "7b062161-db67-4ae4-b591-1ee242dcebb3",
      "name": "Online"
    }
  }
}

Action: Copy the url field from the response. This is the checkout link you will share with your customers:

https://pague-sandbox.lia.com.br/lia/oferta?offer_id=c013d81e-57e9-519e-8f3b-8d161568dbca

Step 5: Share the Checkout URL with Your Customers

The offer URL is the checkout page where customers can complete their purchase. You can:

  1. Send via email or SMS: Include the URL in customer communications
  2. Embed on your website: Add a “Buy Now” button that links to the URL
  3. Share on social media: Post the link directly for customers to access

When customers visit the URL, they will:

  1. See the product details and available payment options
  2. Select their preferred payment method
  3. Fill in their personal information
  4. Complete the purchase

When testing the checkout in sandbox, no e-mail or SMS is sent. Enter 123456 whenever a verification code is requested. See Environments.


Webhooks allow you to receive real-time notifications when events occur (e.g., order created, payment received, billing completed).

Available Entities and Events

EntityEventsDescription
orderin_progress, finished, canceled, access_revoked, access_restoredOrder lifecycle events
billingwaiting_payment, active, finished, canceledBilling status changes
billpending, paid, canceled, overdueIndividual bill payment events

Request

curl --location 'https://external-api-sandbox.lia.com.br/external_api/v1/webhooks' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--data '{
  "name": "Order Status Webhook",
  "url": "https://your-domain.com/webhooks/lia/orders",
  "entity": "order",
  "events": ["finished", "canceled"],
  "verb": "post"
}'

Request Parameters

ParameterDescriptionRequiredType
nameDescriptive name for the webhookYesString
urlYour endpoint URL that will receive webhook notifications. Must be a public https:// URLYesString
entityEntity type: order, billing, or billYesString
eventsArray of events to listen forYesArray
verbHTTP method: post, put or get (recommended: post)YesString

Response

{
  "id": "c6513893-c0ed-56bc-ab8e-fc581d390135",
  "name": "Order Status Webhook",
  "url": "https://your-domain.com/webhooks/lia/orders",
  "entity": "order",
  "events": [
    "finished",
    "canceled"
  ],
  "target": "standard",
  "params": null,
  "verb": "post",
  "created_at": "2024-03-15T16:00:00.000-03:00",
  "updated_at": "2024-03-15T16:00:00.000-03:00"
}

Webhook Payload Example

When an event occurs, Lia will send a POST request to your webhook URL with the following payload (data abbreviated; see Order Events for the full payload):

{
  "api_version": "1.0",
  "entity": "order",
  "event": "finished",
  "data": {
    "id": "3c6d7169-75c1-567f-9b78-09657791d725",
    "status": "finished",
    "customer_name": "João Silva",
    "customer_document": "12345678901",
    "customer_type": "person",
    "offer": {
      "id": "c013d81e-57e9-519e-8f3b-8d161568dbca",
      "name": "Standard Payment Plan",
      "amount_cents": 299700,
      "product": {
        "id": "ce375417-b11a-527a-85f1-30d1202cd5c3",
        "name": "Complete Web Development Course",
        "description": "Learn full-stack web development with React, Node.js, and PostgreSQL. Includes 100+ hours of video content, projects, and lifetime support."
      }
    },
    "billings": [
      {
        "id": "3e6575aa-4b78-5e12-83ad-2f96b23aef37",
        "status": "active",
        "amount_cents": 299700,
        "installments": 24
      }
    ],
    "created_at": "2024-03-15T17:30:00.000-03:00",
    "finished_at": "2024-03-15T17:35:00.000-03:00",
    "contact": {
      "email": "joao.silva@example.com",
      "phone": "5511999999999"
    },
    "order_bump_offers": []
  },
  "id": "9b2f6a3c1d8e4f5a6b7c8d9e0f1a2b3c"
}

Best Practices:

  • Return a 200 OK response immediately upon receiving the webhook
  • Process the webhook data asynchronously to avoid timeouts
  • Validate the webhook data before processing
  • Implement retry logic in case of temporary failures
  • Store webhook delivery history for debugging

Common Scenarios

Scenario 1: Simple Product with PIX Payment Only

# Create product
curl --location 'https://external-api-sandbox.lia.com.br/external_api/v1/products' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--data '{
  "name": "eBook: Digital Marketing Guide",
  "full_amount_cents": 4900,
  "kind_id": "8a145abf-9463-4088-bbd0-978c3a1312cf",
  "shift_id": "7b062161-db67-4ae4-b591-1ee242dcebb3",
  "access_period": "lifetime",
  "description": "Complete guide to digital marketing in 2024"
}'

# Create offer with PIX only
curl --location 'https://external-api-sandbox.lia.com.br/external_api/v1/offers' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--data '{
  "offer": {
    "product_id": "PRODUCT_ID_FROM_PREVIOUS_RESPONSE",
    "name": "PIX Payment",
    "amount_cents": 4900
  },
  "payment_configurations": [
    {
      "payment_type": "upfront",
      "payment_methods": ["pix"],
      "expires_in_hours": 48
    }
  ]
}'

Scenario 2: High-Value Course with Flexible Payment Options

# Create offer with multiple payment options
curl --location 'https://external-api-sandbox.lia.com.br/external_api/v1/offers' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--data '{
  "offer": {
    "product_id": "ce375417-b11a-527a-85f1-30d1202cd5c3",
    "name": "Flexible Payment Options",
    "amount_cents": 299700
  },
  "payment_configurations": [
    {
      "payment_type": "upfront",
      "payment_methods": ["pix"],
      "expires_in_hours": 72
    },
    {
      "payment_type": "upfront",
      "payment_methods": ["credit_card"],
      "expires_in_hours": 24,
      "interest_rate": 0.0199,
      "max_installments": 12
    },
    {
      "payment_type": "financed",
      "financed_type": "bolepix",
      "allowed_down_payment_methods": ["pix"],
      "payment_methods": ["pix", "boleto"],
      "expires_in_hours": 48,
      "interest_rate": 0.0299,
      "max_installments": 18,
      "down_payment_type": "percentage",
      "down_payment_value": 0.15
    }
  ]
}'

Monitoring Your Sales

After setting up your integration, you can monitor orders and payments through the API:

List All Orders

curl --location 'https://external-api-sandbox.lia.com.br/external_api/v1/orders' \
--header 'Authorization: Bearer YOUR_API_TOKEN'

Get Specific Order Details

curl --location 'https://external-api-sandbox.lia.com.br/external_api/v1/orders/ORDER_ID' \
--header 'Authorization: Bearer YOUR_API_TOKEN'

List All Billings

curl --location 'https://external-api-sandbox.lia.com.br/external_api/v1/billings' \
--header 'Authorization: Bearer YOUR_API_TOKEN'

Error Handling

The API uses standard HTTP status codes:

Status CodeDescription
200Success
201Resource created successfully
400Bad request (invalid parameters)
401Unauthorized (invalid or missing API token), with an empty body {}
403Forbidden (access denied, or blocked IP)
404Resource not found
422Unprocessable entity (validation errors)
429Too many requests (see Rate Limits)
500Internal server error

Example Error Response

Errors return status, error and a messages list, with the messages in Portuguese:

{
  "status": 422,
  "error": "record_invalid",
  "messages": [
    {
      "attribute": "kind",
      "message": "Kind é obrigatório(a)"
    },
    {
      "attribute": "full_amount_cents",
      "message": "Full amount cents deve ser maior ou igual a 500"
    }
  ]
}

Next Steps

Now that you have successfully integrated with Lia’s checkout:

  1. Test the complete flow in the sandbox environment
  2. Implement webhook handlers to process order and payment events
  3. Monitor your integration using the order and billing list endpoints
  4. Switch to production when ready by updating the base URL and API token

For detailed API reference documentation, see: