Skip to main content

copper@1.0.0

request(method, path, body, options)
upsertLead(properties, [match])

This adaptor exports the following from common:

as()
combine()
cursor()
dataPath()
dataValue()
dateFns
each()
field()
fields()
fn()
fnIf()
group()
lastReferenceValue()
map()
merge()
scrubEmojis()
sourceValue()
util

Functions​

request​

request(method, path, body, options) ⇒ Operation

Make a general HTTP request to the Copper API

ParamTypeDescription
methodstringHTTP method to use
pathstringPath to resource, relative to https://api.copper.com/developer_api/v1
bodyobjectObject which will be attached to the request body
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example

request('POST', 'leads/search', { page_size: 25 });

upsertLead​

upsertLead(properties, [match]) ⇒ Operation

Create or update a Copper lead. If no lead matches, a new lead is created. If exactly one lead matches, it is updated. If several leads match, an error is thrown. By default leads are matched on properties.email.email. Writes the created or updated lead to state.data.

ParamTypeDescription
propertiesobjectLead fields to set, as described in the Copper lead schema
[match]LeadMatchMatch criteria. Defaults to matching on email.

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example: Upsert a lead, matching on email

upsertLead({
name: 'Ada Lovelace',
email: { email: 'ada@example.com', category: 'work' },
company_name: 'Analytical Engines',
});

Example: Upsert a lead from a lemlist activity

upsertLead($ => ({
name: `${$.data.leadFirstName} ${$.data.leadLastName}`,
email: { email: $.data.leadEmail, category: 'work' },
company_name: $.data.leadCompanyName,
}));

Example: Upsert a lead, matching on name

upsertLead(
{ name: 'Ada Lovelace', title: 'Mathematician' },
{ field_name: 'name', field_value: 'Ada Lovelace' }
);

Interfaces​

HttpState​

State object

Properties

NameDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

LeadMatch​

Lead match criteria

Properties

NameTypeDescription
field_namestringThe field to match on: email, name, or a custom field
field_valuestringThe value to match

RequestOptions​

Options provided to the HTTP request

Properties

NameTypeDescription
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
queryobjectAn object of query parameters to be encoded into the URL.
headersobjectAn object of headers to append to the request.
parseAsstringParse the response body as json, text or stream. By default will use the response headers.
timeoutnumberRequest timeout in ms. Default: 300 seconds.