Import Data in Bulk
POST https://api.chartmogul.com/v1/data_sources/{DATA_SOURCE_UUID}/json_imports
Imports or updates multiple records with a single API query.
curl -X POST "https://api.chartmogul.com/v1/data_sources/ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba/json_imports" \
-u YOUR_API_KEY: \
-H "Content-Type: application/json" \
-d '{
"external_id": "ds_import_1",
"customers": [
{
"external_id": "scus_0001",
"name": "Andrew Jones",
"email": "[email protected]",
"country": "US",
"state": "California",
"city": "San Francisco",
"zip": "90210",
"company": "CA Printing Company",
"lead_created_at": "2023-05-14 00:00:00",
"free_trial_started_at": "2023-06-01 00:00:00"
}
],
"plans": [
{
"name": "Gold Biannual",
"external_id": "gold_biannual",
"interval_count": 6,
"interval_unit": "month"
}
],
"invoices": [
{
"external_id": "inv_001",
"date": "2023-04-02 21:37:00",
"due_date": "2023-05-02 21:37:00",
"currency": "USD",
"customer_external_id": "scus_0001"
},
{
"external_id": "inv_002",
"date": "2023-05-02 21:37:00",
"due_date": "2023-06-02 21:37:00",
"currency": "USD",
"customer_external_id": "scus_0001"
},
{
"external_id": "inv_003",
"date": "2023-06-02 21:37:00",
"due_date": "2023-07-02 21:37:00",
"currency": "USD",
"customer_external_id": "scus_0001"
}
],
"line_items": [
{
"type": "subscription",
"amount_in_cents": 1000,
"quantity": 1,
"invoice_external_id": "inv_001",
"plan_external_id": "gold_biannual",
"subscription_external_id": "sub_0001",
"service_period_start": "2023-04-02 21:37:00",
"service_period_end": "2023-05-02 21:37:00"
},
{
"type": "subscription",
"amount_in_cents": 1000,
"quantity": 1,
"invoice_external_id": "inv_002",
"plan_external_id": "gold_biannual",
"subscription_external_id": "sub_0001",
"service_period_start": "2023-05-02 21:37:00",
"service_period_end": "2023-06-02 21:37:00"
},
{
"type": "subscription",
"amount_in_cents": 1500,
"quantity": 1,
"invoice_external_id": "inv_003",
"plan_external_id": "gold_biannual",
"subscription_external_id": "sub_0001",
"service_period_start": "2023-06-02 21:37:00",
"service_period_end": "2023-07-02 21:37:00"
}
],
"transactions": [
{
"invoice_external_id": "inv_001",
"external_id": "trans_0001",
"type": "payments",
"result": "successful",
"date": "2023-04-02 21:37:00"
},
{
"invoice_external_id": "inv_002",
"external_id": "trans_0002",
"type": "payment",
"result": "failed",
"date": "2023-05-02 21:37:00"
},
{
"invoice_external_id": "inv_002",
"external_id": "trans_0003",
"type": "payment",
"result": "successful",
"date": "2005-05-03 21:37:00"
},
{
"invoice_external_id": "inv_003",
"external_id": "trans_0004",
"type": "payment",
"result": "successful",
"date": "2023-06-03 21:37:00"
}
],
"subscription_events": [
{
"external_id": "event_0001",
"subscription_set_external_id": "set_0001",
"subscription_external_id": "sub_001",
"customer_external_id": "scus_0001",
"plan_external_id": "gold_biannual",
"event_date": "2023-04-02 21:37:00",
"effective_date": "2023-04-02 21:37:00",
"event_type": "subscription_start",
"currency": "USD",
"amount_in_cents": 150000,
"quantity": 1
}
],
"contacts": [
{
"customer_external_id": "scus_0001",
"external_id": "cont_0001",
"first_name": "Andrew",
"last_name": "Jones",
"title": "CEO",
"email": "[email protected]",
"phone": "+1234567890"
}
],
"customer_notes": [
{
"customer_external_id": "scus_0001",
"type": "note",
"author_email": "[email protected]",
"text": "Customer interested in upgrading plan.",
"created_at": "2023-06-01T10:00:00Z"
}
],
"tasks": [
{
"customer_external_id": "scus_0001",
"task_details": "Follow up on upgrade discussion",
"assignee": "[email protected]",
"due_date": "2023-06-15"
}
],
"opportunities": [
{
"customer_external_id": "scus_0001",
"owner": "[email protected]",
"pipeline": "New Business",
"pipeline_stage": "Discovery",
"estimated_close_date": "2023-09-01",
"amount_in_cents": 100000,
"currency": "USD"
}
],
"customer_tags": [
{
"customer_external_id": "scus_0001",
"tags": ["important", "enterprise"]
}
],
"custom_attributes": [
{
"type": "String",
"key": "industry",
"associated_object": "customer"
}
],
"custom_attribute_values": [
{
"associated_object": "customer",
"key": "industry",
"value": "Technology",
"associated_object_identifier": {
"method": "external_id",
"value": "scus_0001"
}
}
]
}'
{
"id": "4815d987-1234-11ee-a987-978df45c5114",
"data_source_uuid": "1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba",
"status": "queued",
"external_id": "ds_import_1",
"status_details": {},
"created_at": "2023-06-01T23:55:23Z",
"updated_at": "2023-06-01T23:55:23Z"
}
This endpoint enables the import or update of multiple records with a single API query. You can import or update different types of objects at the same time.
The Import Data in Bulk endpoint is an alternative to importing data via Import API single-object endpoints (such as Create a Customer or Import Invoices).
Importing multiple records for a customer.
When using the Bulk Import endpoint, group all records and payloads for the same customer in a single API request. Send subsequent requests for this customer only after all previous API requests containing records for this customer have finished processing.
Payload size and number of records per Bulk Import API request.
The JSON payload size should not exceed 5MB.
There’s no exact limit on the number of customers (and corresponding records) you can import in a single Bulk Import API request. It depends on multiple factors, such as upload speed on the requester side, the data set size or the number of records (such as invoices, line items, transactions, subscription events, etc.) per customer. Our recommendation is to test the import in a test source to fine-tune the number of customers (and corresponding records) per API query. In most cases, it’s optimal to import between 100 and 1,000 customers (and corresponding records such as invoices, line items, etc.) per Bulk Import API query.
Here’s the list of object types you can import:
| Type of object | Corresponding single-object endpoint |
|---|---|
| Customers | Create a Customer |
| Plans | Create a Plan |
| Invoices | Import Invoices |
| Line items | Import Invoices or Create a Line Item |
| Transactions | Import Invoices or Create a Transaction |
| Subscription events | Create a Subscription Event |
| Contacts | Create a Contact |
| Notes & Call Logs | Create a Note or Call Log |
| Tasks | Create a Task |
| Opportunities | Create an Opportunity |
| Customer Tags | Add Tags to a Customer |
| Custom Attributes | Add Custom Attributes to a Customer |
data_source_uuid as a path or body parameter.
The data_source_uuid can be provided either as a URL path parameter (/data_sources/{DATA_SOURCE_UUID}/json_imports) or as a JSON body parameter using the /v1/json_imports endpoint. Use the body parameter when importing objects that are not data source-scoped (such as notes and call logs, tasks, opportunities, and customer tags), or when you want to mix data source-scoped and non-scoped objects in a single request.
Path parameters
data_source_uuidstring optional- The ChartMogul UUID of the source where you want to store the imported objects. Required if
data_source_uuidis not provided in the request body.
Body parameters
external_idstring required-
A unique identifier specified by you for the import.
data_source_uuidstring optional-
The ChartMogul UUID of the source where you want to store the imported objects. Required if
data_source_uuidis not provided as a URL path parameter. customersarray(object) optional-
Array of
customerobjects to import under the specifieddata_source.external_idstring required-
A unique identifier specified by you for the customer. Typically an identifier from your internal system. Accepts alphanumeric characters.
-
Use an existing external ID to update a customer rather than create a new one.
companystring optional-
The customer's company or organisation.
countrystring optional-
Country code of customer's location as per ISO-3166 alpha-2 standard.
statestring optional-
The US state where the customer is located—the US state code as per the ISO-3166-2 standard. For example, US-CA or US-NY.
citystring optional-
City of the customer's location.
zipstring optional-
Zip code of the customer's location.
lead_created_atdatetime optional-
Time at which this customer was established as a lead. Must be an ISO 8601-formatted time in the past. The timezone defaults to UTC unless otherwise specified.
free_trial_started_atdatetime optional-
Time at which this customer started a free trial of your product or service. Must be an ISO 8601-formatted time in the past. The timezone defaults to UTC unless otherwise specified. This is expected to be the same as or after the lead_created_at value.
plansarray(object) optional-
Array of
planobjects to import under the specifieddata_source.namestring required-
Display name of the plan. Accepts alphanumeric characters.
interval_countint32 required-
The frequency of billing interval. Accepts integers greater than 0. eg. 6 for a half-yearly plan.
interval_unitstring required-
The unit of billing interval. One of day, month or year. eg. month for the above half-yearly plan.
external_idstring optional-
A unique identifier specified by you for the plan. Typically an identifier from your internal system. Accepts alphanumeric characters. If not provided, ChartMogul will automatically generate one.
-
Use an existing external ID to update a plan rather than create a new one.
invoicesarray(object) optional-
Array of
invoiceobjects to import under the specifieddata_source.customer_external_idstring required-
A unique identifier specified by you for the customer. Typically an identifier from your internal system. Accepts alphanumeric characters.
external_idstring required-
A unique identifier specified by you for the invoice. Typically the invoice number in your system. Accepts alphanumeric characters.
-
Use an existing external ID to update an invoice rather than create a new one.
datedatetime required-
The date on which this invoice was raised. Must be an ISO 8601-formatted time. The timezone defaults to UTC unless otherwise specified. The time defaults to 00:00:00 unless specified otherwise.
due_datedatetime optional-
The date by which this invoice must be paid. Must be an ISO 8601-formatted time. The timezone defaults to UTC unless otherwise specified. The time defaults to 00:00:00 unless specified otherwise.
currencystring optional-
The three-letter currency code of the currency in which this invoice is being billed, e.g. USD, EUR, GBP. You can refer to our full list of supported currencies.
collection_methodstring optional default: "automatic"-
Specifies how the payment for the invoice is collected.
automatic—Payments are processed within the billing system without manual intervention (e.g., credit cards, PayPal, direct debits).manual—Payments are handled outside the billing system and require customer or business action (e.g., checks, manual bank transfers).
line_itemsarray(object) optional-
Array of
line_itemobjects to import under the specifieddata_source.invoice_external_idstring required-
A unique identifier specified by you for the invoice to which this line item belongs to. Typically the invoice number in your system. Accepts alphanumeric characters.
typestring required-
One of
subscription,one_time, ortrial. -
On October 2, 2025, we introduced
trialas an invoice line item type. We’re gradually making the functionality available to all accounts. Learn more. amount_in_centsint32 required-
The final amount charged towards this line item, for the specified quantity and service period, after discounts, taxes, and fees have been applied. Expected in cents (or pence for GBP, etc.). This is the amount that is primarily used to calculate MRR.
external_idstring optional-
A unique identifier specified by you for the line item. Typically an identifier from your internal system. Accepts alphanumeric characters.
-
Use an existing external ID to update a line item rather than create a new one.
subscription_external_idstring optional-
A reference identifier for the subscription in your system. Accepts alphanumeric characters. Required for subscription line items. Irrelevant for one_time line items.
subscription_set_external_idstring optional-
A reference identifier for a set of subscriptions in order to group several subscriptions into one set. Only relevant for subscription line items
plan_external_idstring optional-
A unique identifier specified by you for the plan. Typically an identifier from your internal system. Accepts alphanumeric characters. If Plan external_id is not provided during Plan creation, ChartMogul will automatically generate one and you'll need to fetch the Plan to find the automatically generated Plan external_id.
service_period_startdatetime optional-
The start of the service period for which this subscription is being charged. Required for subscription line items. Irrelevant for one_time line items. Must be an ISO 8601-formatted time. The timezone defaults to UTC unless otherwise specified. The time defaults to 00:00:00 unless specified otherwise.
service_period_enddatetime optional-
The end of the service period for which this subscription is being charged. Required for subscription line items. Irrelevant for one_time line items. Must be an ISO 8601-formatted time. The timezone defaults to UTC unless otherwise specified. The time defaults to 00:00:00 unless specified otherwise.
proratedboolean optional default: false-
If this is a prorated line_item, then set this attribute to true. Accepted for subscription line items. Irrelevant for one_time line items.
proration_typestring optional-
If not provided, or set to
differential, prorated line items are classified as an upgrade or downgrade and added to previously calculated MRR and subscription quantity. When there's a plan change,differentialbehaves likefulland does not take previously calculated MRR and subscription quantity into consideration.If set to
full, prorated line items have a partial service period and do not take previously calculated MRR and subscription quantity into consideration.If set to
differential_mrr, the amount from this prorated line item behaves likedifferentialproration, which means it is added to previously calculated MRR. The quantity from this prorated line item behaves likefullproration, which means it is not added to the previously calculated subscription quantity.If set to
differential_always, prorated line items are always classified as an upgrade or downgrade and added to previously calculated MRR and subscription quantity, even when there's a plan change.Accepted for subscription line items. Irrelevant for one_time line items.
descriptionstring optional-
A short description of the non-recurring item being charged to the customer. Accepted for one_time line items. Ignored for subscription line items.
quantityint32 optional default: 1-
The quantity/seats of the subscription being billed by this line item. Can be any non-zero integer. Defaults to 1. Quantity value does not impact calculation of MRR. It is used for additional segmentation by subscription quantity and generating Subscription Quantity charts.
discount_amount_in_centsint32 optional default: 0-
If any discount has been applied to this line item, then the discount amount in cents. Defaults to 0. Discount amount does not impact calculation of MRR.
discount_codestring optional-
If a discount has been applied to this line item, then an optional reference code to identify the discount.
tax_amount_in_centsint32 optional default: 0-
The tax that has been applied to this line item, in cents. Defaults to 0. If specified, we exclude tax amount from MRR.
transaction_fees_in_centsint32 optional-
The final total transaction fees paid to billing provider and/or payment processor for this line item. Expected in cents (or pence for GBP, etc.).
transaction_fees_currencystring optional-
The three-letter currency code for transaction_fees_in_cents, e.g. USD, EUR, GBP. You can refer to our full list of supported currencies.
discount_descriptionstring optional-
A short description of discount_amount_in_cents.
event_orderint32 optional-
A numeric value that determines the sequence in which events are processed when multiple events occur at the same timestamp.
transactionsarray(object) optional-
Array of transaction objects to import under the specified
data_source.invoice_external_idstring required-
A unique identifier specified by you for the invoice to which this transaction belongs to. Typically the invoice number in your system. Accepts alphanumeric characters.
typestring required-
Either
paymentorrefund. resultstring required-
Either
successfulorfailed. datedatetime required-
The timestamp of when the transaction was attempted. Must be an ISO 8601-formatted time. The timezone defaults to UTC unless otherwise specified. The time defaults to 00:00:00 unless specified otherwise.
external_idstring optional-
A unique identifier specified by you for the transaction. Typically an identifier from your internal system. Accepts alphanumeric characters.
-
Use an existing external ID to update a transaction rather than create a new one.
amount_in_centsint32 optional-
The partial amount paid/refunded for this invoice. Expected in cents (or pence for GBP, etc.). If this field is not mentioned it will default to full amount. The sum of the partial payments/refunds should not exceed the invoiced amount.
subscription_eventsarray(object) optional-
Array of
subscription_eventobjects to import under the specifieddata_source.customer_external_idstring required-
A unique identifier specified by you for the customer. Typically an identifier from your internal system. Accepts alphanumeric characters.
event_typestring required-
One of the ten subscription event types. See table here for details.
event_datedatetime required-
The date when this event was raised. Must be an ISO 8601-formatted time. The timezone defaults to UTC unless otherwise specified. The time defaults to 00:00:00 unless specified otherwise.
effective_datedatetime required-
The date when this event takes effect. Must be an ISO 8601-formatted time. The timezone defaults to UTC unless otherwise specified. The time defaults to 00:00:00 unless specified otherwise.
subscription_external_idstring required-
A unique identifier specified by you for the subscription which the subscription event is being added. Typically an identifier from your internal system. Accepts alphanumeric characters. Required for all subscription event types except subscription_event_retracted event type.
subscription_set_external_idstring optional-
A reference identifier for a set of subscriptions in order to group several subscriptions into one set.
external_idstring optional-
A unique identifier specified by you for the subscription event. Typically an identifier from your internal system. Accepts alphanumeric characters.
-
Use an existing external ID to update a subscription event rather than create a new one.
plan_external_idstring optional-
A unique identifier specified by you for the plan. Typically an identifier from your internal system. Accepts alphanumeric characters. Required for
subscription_start,subscription_start_scheduled,subscription_updated, andsubscription_update_scheduledevent types. currencystring optional-
The three-letter currency code of the currency in which this subscription is being billed, e.g. USD, EUR, GBP. You can refer to our full list of supported currencies. Required for
subscription_start,subscription_start_scheduled,subscription_updated, andsubscription_update_scheduledevent types. amount_in_centsint32 optional-
The final amount charged towards this subscription on subscription start or subscription update, for the specified quantity and plan, after discounts, taxes, and fees have been applied. Expected in cents (or pence for GBP, etc.). Required for
subscription_start,subscription_start_scheduled,subscription_updated, andsubscription_update_scheduledevent types. quantityint32 optional default: 1-
The quantity of subscription addressed by this subscription event. Can be any non-zero integer. Defaults to 1. Required for
subscription_start,subscription_start_scheduled,subscription_updated, andsubscription_update_scheduledevent types. tax_amount_in_centsint32 optional default: 0-
The tax in cents that has been applied to subscription addressed by this subscription event. Defaults to 0.
retracted_event_idstring optional-
Required for subscription_event_retracted event type. Refers to the event id of the scheduled subscription event that is being retracted.
contactsarray(object) optional-
Array of
contactobjects to import.customer_external_idstring required- A unique identifier specified by you for the customer to associate the contact with. Typically an identifier from your internal system. Accepts alphanumeric characters.
external_idstring optional- A unique identifier specified by you for the contact. Typically an identifier from your internal system. Accepts alphanumeric characters.
positioninteger optional- Sets the position of the contact in the UI. The first contact has a position of 1. If the number is higher than the number of contacts associated with this customer then the position itself is used as-is.
first_namestring optional- The first name of the contact.
last_namestring optional- The last name of the contact.
titlestring optional- The job title of the contact, e.g. "CEO".
emailstring optional- The contact's email address. Needs to be unique for the customer.
phonestring optional- The contact's phone number.
linked_instring optional- The URL of the contact's LinkedIn profile.
twitterstring optional- The URL of the contact's Twitter profile.
notesstring optional- Additional notes or comments about the contact. Newline can be appended with
\nin the string. last_seenstring optional- A timestamp of when the contact was last active, in the ISO 8601 format.
customer_notesarray(object) optional-
Array of note and call log objects to import.
customer_external_idstring required- A unique identifier specified by you for the customer to associate the note or call log with. Typically an identifier from your internal system. Accepts alphanumeric characters.
typestring required- The type of customer note. Can be either
noteorcall. author_emailstring optional- The email of the author of the note or call log. The email has to match a team member who belongs to the account.
textstring optional- Contents of the note or call log as plain text or HTML.
call_durationinteger optional- Relevant for type
call. Duration of the call in seconds. Defaults to 60 seconds if not provided. created_atstring optional- The date and time when this
noteorcallwas made. Defaults tonowif not provided. Must be an ISO 8601-formatted time in the past. The timezone defaults to UTC unless otherwise specified.
tasksarray(object) optional-
Array of
taskobjects to import.customer_external_idstring required- A unique identifier specified by you for the customer associated with the task. Typically an identifier from your internal system. Accepts alphanumeric characters.
task_detailsstring required- A description of the task up to 255 characters.
assigneestring required- The email address of the team member assigned to the task.
due_datestring required- The date when the task is due. Must be an ISO 8601-formatted date.
completed_atstring optional- The date when the task was completed. Must be an ISO 8601-formatted date in the past.
opportunitiesarray(object) optional-
Array of
opportunityobjects to import.customer_external_idstring required- A unique identifier specified by you for the customer associated with the opportunity. Typically an identifier from your internal system. Accepts alphanumeric characters.
ownerstring required- The email address of the team member with a CRM Pro seat who is the primary salesperson responsible for this opportunity.
pipelinestring required- The sales pipeline name. The pipeline must already exist in ChartMogul. Use one of the default sales pipelines:
New BusinessorRenewals, or set up a new one. pipeline_stagestring required- The name of the current deal stage within the sales pipeline.
estimated_close_datestring required- The date when the opportunity is expected to close. Must be an ISO 8601-formatted date.
amount_in_centsinteger required- Amount in cents (or pence for GBP, etc.) of expected close value of this opportunity.
currencystring required- The three-letter currency code of the currency of the expected close value, e.g.
USD,EUR, orGBP. Read the full list of supported currencies. typestring optional- The opportunity type. Both
recurringandarrrepresent recurring revenue opportunities. Userecurringwhen the value is expressed as MRR, andarrwhen it is expressed as ARR. Useone-timefor opportunities expected to convert into one-time deals. forecast_categorystring optional- The opportunity's grouping based on its likelihood of closing. One of five pre-defined forecast categories:
pipeline,best_case,committed,lost, orwon. If not provided, it is set to the default forecast category for a given pipeline stage. win_likelihoodinteger optional- An integer between 0 and 100 representing the likelihood (as a percentage) that this opportunity will successfully close. If not provided, it is set to the default win likelihood for a given pipeline stage.
customer_tagsarray(object) optional-
Array of customer tag objects to import.
customer_external_idstring required- A unique identifier specified by you for the customer to add tags to. Typically an identifier from your internal system. Accepts alphanumeric characters.
tagsarray(string) required- An array of tags to be added to the customer.
custom_attributesarray(object) optional-
Array of custom attribute schema definitions. Use this to define new custom attributes before setting their values via
custom_attribute_values.keystring required- The name of the custom attribute. Accepts alphanumeric characters and underscores.
typestring required- The data type of the custom attribute. Can be one of
String,Integer,Decimal,Timestamp, orBoolean. associated_objectstring required- The type of object this custom attribute is associated with. One of
customer,contact, oropportunity.
custom_attribute_valuesarray(object) optional-
Array of custom attribute value objects. Sets the value of a custom attribute on a specific customer, contact, or opportunity.
associated_objectstring required-
The type of object to set the custom attribute value on. One of
customer,contact, oropportunity. keystring required-
The name of the custom attribute. Must match an existing custom attribute key for the given
associated_object. valuestring required-
The value of the custom attribute. Must match the data type specified for this attribute.
associated_object_identifierobject required-
Identifies the specific object to set the custom attribute value on.
methodstring required- The method used to identify the object. For
customerandcontact, one ofuuid,email, orexternal_id. Foropportunity, onlyuuidis supported. valuestring required- The identifier value corresponding to the chosen
method.
sourcestring optional-
Optional label indicating the origin of this custom attribute value, e.g. the name of an integration or script. Not included in the response.