Orders

The Order Object

1class Order
2 attr_accessor :id,
3 :name,
4 :description,
5 :account_id,
6 :organization_id,
7 :start_date,
8 :end_date,
9 :total_amount,
10 :estimated_tax,
11 :billed_amount_no_tax,
12 :billed_tax,
13 :total_billed_amount,
14 :pending_billing_amount,
15 :order_lines,
16 :account,
17 :creation_state
18end
19
20class OrderLine
21 attr_accessor :id,
22 :order_id,
23 :agent_id,
24 :name,
25 :description,
26 :start_date,
27 :end_date,
28 :total_amount,
29 :billed_amount_without_tax,
30 :billed_tax,
31 :total_billed_amount,
32 :agent,
33 :order_line_attributes,
34 :creation_state
35end
36
37class OrderLineAttribute
38 attr_accessor :agent_attribute_id,
39 :quantity,
40 :currency,
41 :pricing
42end
43
44class OrderLineAttributePricing
45 attr_accessor :event_name,
46 :charge_type,
47 :price_point,
48 :pricing_model,
49 :billing_frequency
50end
51
52class PricePoint
53 attr_accessor :currency,
54 :unit_price,
55 :tiers,
56 :min_quantity,
57 :included_quantity
58end
59
60class Tier
61 attr_accessor :lower_bound,
62 :upper_bound,
63 :price
64end
65
66module ChargeType
67 ONE_TIME = "oneTime"
68 RECURRING = "recurring"
69 USAGE = "usage"
70 SEAT_BASED = "seatBased"
71end
72
73module PricingModelType
74 PER_UNIT = "PerUnit"
75 VOLUME_PRICING = "VolumePricing"
76 GRADUATED_PRICING = "GraduatedPricing"
77end
78
79module BillingFrequency
80 MONTHLY = "Monthly"
81 QUARTERLY = "Quarterly"
82 SEMI_ANNUAL = "SemiAnnual"
83 ANNUAL = "Annual"
84end
85
86module CreationState
87 DRAFT = "draft"
88 ACTIVE = "active"
89end
90
91module Currency
92 USD = "USD"
93 EUR = "EUR"
94 GBP = "GBP"
95end

Attributes

AttributeTypeDescription
idstringUnique identifier for the order
namestringName of the order
descriptionstringOptional description of the order
account_idstringID of the account this order belongs to
organization_idstringOrganization ID the order belongs to
start_datestringStart date of the order
end_datestringOptional end date of the order
total_amountnumberTotal amount of the order
estimated_taxnumberEstimated tax amount
billed_amount_no_taxnumberBilled amount without tax
billed_taxnumberBilled tax amount
total_billed_amountnumberTotal billed amount including tax
pending_billing_amountnumberAmount pending billing
order_linesarrayList of order lines
accountobjectOptional account information
creation_statestringOrder creation state (‘draft’ or ‘active’)

Order Line Attributes

AttributeTypeDescription
idstringUnique identifier for the order line
order_idstringID of the order this line belongs to
agent_idstringID of the agent
namestringName of the order line
descriptionstringDescription of the order line
start_datestringStart date of the order line
end_datestringOptional end date of the order line
total_amountnumberTotal amount of the order line
billed_amount_without_taxnumberBilled amount without tax
billed_taxnumberBilled tax amount
total_billed_amountnumberTotal billed amount including tax
agentobjectOptional agent information
order_line_attributesarrayList of order line attributes
creation_statestringOrder line creation state (‘draft’ or ‘active’)

Order Line Attribute

AttributeTypeDescription
agent_attribute_idstringID of the agent attribute
quantitynumberQuantity of the attribute
currencystringCurrency code
pricingobjectPricing configuration

Order Line Attribute Pricing

AttributeTypeDescription
event_namestringName of the event
charge_typestringType of charge (‘oneTime’, ‘recurring’, ‘usage’, ‘seatBased’)
price_pointobjectPrice point configuration
pricing_modelstringType of pricing model (‘PerUnit’, ‘VolumePricing’, ‘GraduatedPricing’)
billing_frequencystringBilling frequency (‘Monthly’, ‘Quarterly’, ‘SemiAnnual’, ‘Annual’)

Price Point

AttributeTypeDescription
currencystringCurrency code
unit_pricenumberBase unit price
tiersarrayList of pricing tiers
min_quantitynumberMinimum quantity
included_quantitynumberIncluded quantity

Tier

AttributeTypeDescription
lower_boundnumberLower bound of the tier
upper_boundnumberOptional upper bound of the tier
pricenumberPrice for this tier

API Endpoints

Create an Order

Creates a new order with given data.

SDK Functions

1require 'paid_ruby'
2
3# Initialize the client
4api = Paid::Client.new(
5 token: "YOUR-API-KEY"
6)
7
8order = api.orders.create(
9 name: "AI SDR – Pro plan",
10 customer_id: customer_id, # use either customer_id or customer_external_id for order creation
11 billing_contact_id: billing_contact_id,
12 description: "Annual subscription for AI SDR – Pro plan",
13 start_date: "2025-06-01",
14 end_date: "2026-05-31",
15 currency: "USD",
16 order_lines: [
17 {
18 agent_external_id: "ai_agent_123", # use either agent_id or agent_external_id for order creation
19 name: "AI SDR",
20 description: "AI SDR – agent"
21 }
22 ]
23)

Returns

Returns the Order object upon successful creation. It’s recommended to store the returned order ID in your own system for future reference and operations.

1{
2 "id": "uuid",
3 "organization_id": "uuid",
4 "name": "Enterprise AI Assistant Package",
5 "start_date": "2024-01-01T00:00:00.000Z",
6 "end_date": "2024-12-31T00:00:00.000Z",
7 "order_amount": 0,
8 "estimated_tax": 0,
9 "billed_amount_no_tax": 0,
10 "billed_tax": 0,
11 "pending_billing_amount": 0,
12 "total_billed_amount": 0,
13 "total_amount": 0,
14 "creation_state": "draft",
15 "usage_summary": [],
16 "account": {
17 "id": "uuid",
18 "organization_id": "uuid",
19 "name": "Acme Test Corporation",
20 "email": "contact@acme.com",
21 "phone": "",
22 "website": "https://acme.com",
23 "employee_count": 100,
24 "annual_revenue": 1000000,
25 "tax_exempt_status": "exempt",
26 "creation_source": "api",
27 "external_id": "customer-123",
28 "creation_state": "active",
29 "billing_address": {
30 "city": "New York",
31 "line1": "123 Main St",
32 "line2": "Suite 100",
33 "state": "NY",
34 "country": "USA",
35 "zip_code": "10001"
36 }
37 },
38 "account_id": "uuid",
39 "order_lines": [...]
40}

Retrieve an Order

Retrieves an order by its internal ID.

SDK Functions

1# Retrieve order by its internal ID
2order = api.orders.get(order_id: id)
1{
2 "id": "uuid",
3 "organization_id": "uuid",
4 "name": "Enterprise AI Assistant Package",
5 "start_date": "2024-01-01T00:00:00.000Z",
6 "end_date": "2024-12-31T00:00:00.000Z",
7 "order_amount": 0,
8 "estimated_tax": 0,
9 "billed_amount_no_tax": 0,
10 "billed_tax": 0,
11 "pending_billing_amount": 0,
12 "total_billed_amount": 0,
13 "total_amount": 0,
14 "creation_state": "draft",
15 "usage_summary": [],
16 "account": {
17 "id": "uuid",
18 "organization_id": "uuid",
19 "name": "Acme Test Corporation",
20 "email": "contact@acme.com",
21 "phone": "",
22 "website": "https://acme.com",
23 "employee_count": 100,
24 "annual_revenue": 1000000,
25 "tax_exempt_status": "exempt",
26 "creation_source": "api",
27 "external_id": "customer-123",
28 "creation_state": "active",
29 "billing_address": {
30 "city": "New York",
31 "line1": "123 Main St",
32 "line2": "Suite 100",
33 "state": "NY",
34 "country": "USA",
35 "zip_code": "10001"
36 }
37 },
38 "account_id": "uuid",
39 "order_lines": [...]
40}

Returns

Returns the up-to-date Order object for a valid identifier. Raises an error if get parameters are invalid (e.g. specifying an invalid internal order ID)

List all Orders

Retrieves all orders associated with your organization.

1# List all orders
2orders = api.orders.list()

Returns

Returns the up-to-date list of Order objects.

1[
2 {
3 id: 'uuid',
4 organization_id: 'uuid',
5 name: 'Order 1',
6 start_date: '2024-01-01T00:00:00.000Z',
7 end_date: '2024-12-31T00:00:00.000Z',
8 ...
9 },
10 {
11 id: 'uuid',
12 organization_id: 'uuid',
13 name: 'Order 2',
14 start_date: '2024-01-01T00:00:00.000Z',
15 end_date: '2024-12-31T00:00:00.000Z',
16 ...
17 }
18]

Update Order Lines

Adds/removes order lines for an exisiting order using order’s and agent’s internal IDs. Raises an error if parameters are invalid (e.g. specifying an invalid internal order ID)

SDK Functions

1order = api.orders.lines.update(order_id: id, lines:[
2 {
3 agent_external_id: "sdk-agent-3",
4 name: "Analytics Dashboard Add-on",
5 description: "Real-time analytics and reporting dashboard for AI assistant performance"
6 }
7])
1 "order_lines": [
2 {
3 "id": "uuid",
4 "order_id": "uuid",
5 "name": "Customer Support AI",
6 "description": "AI-powered customer support agent",
7 "total_amount": 0,
8 "billed_amount_without_tax": 0,
9 "billed_tax": 0,
10 "total_billed_amount": 0,
11 "start_date": "2025-05-12T14:46:09.465Z",
12 "end_date": null,
13 "creation_state": "active",
14 "agent_id": "uuid",
15 "agent": {
16 "id": "uuid",
17 "organization_id": "uuid",
18 "name": "Zhalyn Kabyken Updated",
19 "description": "Updated description with more features",
20 "active": true,
21 "external_id": "UPDATED_AI_AGENT_001",
22 "agent_code": "UPDATED_AI_AGENT_TEST"
23 },
24 "order_line_attributes": [
25 {
26 "id": "uuid",
27 "order_line_id": "uuid",
28 "quantity": 0,
29 "currency": "USD",
30 "status": "",
31 "total_amount": 0,
32 "last_billing_date": null,
33 "next_billing_date": null,
34 "billing_cycle_start": null,
35 "billing_cycle_end": null,
36 "creation_state": "active",
37 "agent_attribute_id": "uuid",
38 "agent_attributes": {
39 "id": "uuid",
40 "name": "subscription",
41 "active": true,
42 "agent_id": "uuid"
43 },
44 "pricing": {
45 "taxable": true,
46 "event_name": "subscription",
47 "charge_type": "recurring",
48 "price_points": {
49 "USD": {
50 "tiers": [
51 {
52 "unit_price": 99.99,
53 "max_quantity": 100,
54 "min_quantity": 0
55 }
56 ],
57 "unit_price": 99.99,
58 "min_quantity": 0,
59 "included_quantity": 0
60 }
61 },
62 "pricing_model": "GraduatedPricing",
63 "billing_frequency": "Annual"
64 }
65 },
66 {
67 "id": "uuid",
68 "order_line_id": "uuid",
69 "quantity": 0,
70 "currency": "USD",
71 "status": "",
72 "total_amount": 0,
73 "last_billing_date": null,
74 "next_billing_date": null,
75 "billing_cycle_start": null,
76 "billing_cycle_end": null,
77 "creation_state": "active",
78 "agent_attribute_id": "uuid",
79 "agent_attributes": {
80 "id": "uuid",
81 "name": "subscription 2",
82 "active": true,
83 "agent_id": "uuid"
84 },
85 "pricing": {
86 "taxable": true,
87 "event_name": "subscription 2",
88 "charge_type": "usage",
89 "pricing_model": "VolumePricing",
90 "billing_frequency": "Monthly",
91 "price_points": {
92 "USD": {
93 "unit_price": 99.99,
94 "tiers": [
95 {
96 "unit_price": 99.99,
97 "max_quantity": 100,
98 "min_quantity": 0
99 }
100 ],
101 "min_quantity": 0,
102 "included_quantity": 0
103 }
104 }
105 }
106 },
107 {
108 // additional attributes
109 }
110 ]
111 }
112 ]

Returns

Returns a list of OrderLine objects upon successful addition of order lines.

Activate an Order

Activates a draft order by its internal ID.

SDK Functions

1# Activate order by its internal ID
2 order = api.orders.activate(order_id: id)

Returns

Returns the up-to-date Order object. If the order ID does not exist, this call raises an error.

Delete an Order

Deletes an order by its internal ID.

SDK Functions

1# Delete order by its internal ID
2api.orders.delete(order_id: id)

Returns

This is a void function. It performs the requested operation but does not return any value upon success. If the order ID does not exist, this call raises an error.

Error Handling

The API uses conventional HTTP response codes to indicate the success or failure of requests:

  • 2xx range indicates success
  • 4xx range indicates an error that failed given the information provided
  • 5xx range indicates an error with Paid’s servers

Error Response Format

1{
2 "error": {
3 "message": "Error message",
4 "code": "ERROR_CODE",
5 "details": "Additional error details"
6 }
7}

Common Error Codes

CodeDescription
ORDER_NOT_FOUNDThe specified order does not exist
INVALID_REQUESTThe request was invalid
UNAUTHORIZEDThe API key is invalid
FORBIDDENThe API key doesn’t have permission to access the resource
INTERNAL_SERVER_ERRORAn error occurred on Paid’s servers