1. Imports
  2. Create Import

Imports

Create Import

POST
`/v1/imports`

Examples

Import Contacts

js
        const response = await fetch("https://api.packagex.io/v1/imports", {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY
  },
  body: {
    "data": "data:text/csv;base64,bmFtZSxlbWFpbCxub3Rlcyxsb2NhdGlvbnMKU2VlIFRocmVlcGlvLHNlZS50aHJlZXBpb3FjYmJ3ZHN5ZnNiZnprMmMzaHpod2hAcGFja2FnZXgueHl6LGRyb2lkLApLeWxvIFJlbixiZW4uc29sb3R6Y3lpcGU0ZTMxeXhwYWRiMnNqaXpAcGFja2FnZXgueHl6LEphY2VuPywKS3lsbyBSZW4sLEJlbj8sClJleSBTa3l3YWxrZXIscmV5LnNreXdhbGtlcmhyZXF1cmlwOXNodGtremlzc21tYWFAcGFja2FnZXgueHl6LCwiX19TZWFyY2ggQ29udGFjdHMgVGVzdCxBQSBXcml0ZSBUZXN0IgpIYW4gU29sbywscmVhbD8sCkhhbiBTb2xvLCx1bnJlbGE/LApMdWtlIFNreXdhbGtlcix3cm9uZywsCg==",
    "upload_mode": "sync",
    "action": "merge",
    "duplicate_handling": "use_first",
    "resource": "contact"
  }
});
const import = await response.json();

      

Import Groups

js
        const response = await fetch("https://api.packagex.io/v1/imports", {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY
  },
  body: {
    "data": "data:text/csv;base64,bmFtZSxyZXNvdXJjZSxpZCxsb2NhdGlvbixjaGlsZHJlbgpGcm9kbyBCYWdnaW5zLGNvbnRhY3QsLCwic2FmYS5rYXJpbUBwYWNrYWdleC54eXosSmFtaWUgSm9uZXM6OjpqYW1pZUBwYW55c3VoZW5rby5jb20iCkZyb2RvIEJhZ2dpbnMsbG9jYXRpb24sLCwiV2VXb3JrIDAxOjo6LFdlV29yayAwMjo6OiIKR2FuZGFsZiB0aGUgR3JleSxjb250YWN0LCwsCkdhbmRhbGYgdGhlIEdyZXksY29udGFjdCwsLApBcmFnb3JuIEVsZXNzYXIsY29udGFjdCwsV2VXb3JrIDAxLEphbWllIEpvbmVzOjo6ZG4xZWp2cGd3cjJyZm50dGF0bHF2dkBwYWNrYWdleC54eXoKTGVnb2xhcyBHcmVlbmxlYWYsbG9jYXRpb24sLFdlV29yayAwMiwK",
    "upload_mode": "sync",
    "action": "merge",
    "duplicate_handling": "ignore_all",
    "resource": "group"
  }
});
const import = await response.json();

      

Request Model

This request model represents the payload structure required to create an import operation in the API.


Request Body

upload_mode sync|async
Determines whether the import process runs synchronously (sync) with data or asynchronously (async) without immediate data.

  • If sync, the data field is required.
  • If async, the data field must be null.

data array<object> | base64 | null
The data to be imported, which can be:

  • A base64-encoded file (CSV, XLSX, etc.).
  • null when upload_mode is async.
Show Details
Contact CSV columns
name string (1-255)
Name of the contact (required).
alternate_names string (1-1279)
Comma separated alternate names of the contact. Max 5
email string (max 127)
Primary email of the contact.
alternate_emails_other string (max 127)
Other alternate email.
alternate_emails_personal string (max 127)
Personal alternate email.
alternate_emails_work string (max 127)
Work alternate email.
alternate_emails_social string (max 127)
Social alternate email.
alternate_emails_education string (max 127)
Education alternate email.
phone string (max 31)
Primary phone number.
alternate_phones_home string (max 31)
Home alternate phone.
alternate_phones_mobile string (max 31)
Mobile alternate phone.
alternate_phones_work string (max 31)
Work alternate phone.
alternate_phones_other string (max 31)
Other alternate phone.
alternate_phones_education string (max 31)
Education alternate phone.
address string (max 255)
Primary address of the contact.
alternate_addresses_secondary string (max 255)
Secondary alternate address.
alternate_addresses_home string (max 255)
Home alternate address.
alternate_addresses_work string (max 255)
Work alternate address.
alternate_addresses_education string (max 255)
Education alternate address.
alternate_addresses_other string (max 255)
Other alternate address.
locations string (max 2047)
Comma separated names of locations.
groups string (max 2047)
Comma separated names of groups.
id_number string
Unique identifier.
is_primary boolean
Indicates if this is the primary contact.
notes string (max 255)
Additional notes.
Group CSV columns
name string (1-255)
Name of the group (required).
resource contact|location
Resource type of group (required).
location string (max 63)
name of group location.
children string (max 2047)
Comma separated contact or location names depending on resource.

location_id string | null (optional)
Specifies the location where the import should be applied.

action merge|overwrite|delete
The action to perform on the imported data:

  • merge: Combine new data with existing data.
  • overwrite: Replace existing data.
  • delete: Remove specified data.

duplicate_handling ignore_all|use_first (optional, default: ignore_all)
Defines how duplicate records should be handled.

save_upload boolean (default: true)
Indicates whether the uploaded file should be stored for future reference.

resource contact|group|item|asset
The type of resource being imported.

name string (optional, 3-127 characters)
A human-readable name for the import.

column_mapping object (optional)
A mapping of resource field names to custom column headers in the uploaded file. This allows you to import files whose column headers do not match the expected field names. Keys are the resource field names and values are the corresponding column header strings in the uploaded file. Each header value must be unique.