Use Census with Custom Destinations to create a connection to any destination service of your choice.
list_objects
- Get a list of the objects your API can write to.list_fields
- Get a list of the fields, along with data types and validation rules, for a given object.supported_operations
- Find out what kinds of “writes” can be performed on an object - can new instances be created? Can existing instances be modified?get_sync_speed
- How quickly should Census send data to your API?sync_batch
- Sync one batch of records to your destination, reporting success and failure for each record.list_objects
and list_fields
methods). Census will use this information to populate its mapping API, and guide the users of your Custom API to map tables and columns in their data warehouse to your destination.
Every SaaS application has a different data surface it exposes to the world, and there is some art in deciding how to model SaaS data APIs as objects and fields. This also depends on the operations the SaaS application gives you (see below).
Many SaaS applications / destinations do not provide APIs to discover objects and fields. In this case, your Custom API should return a hard-coded list of objects and fields and return those to Census.
operation
field in the sync_batch call to indicate how the records should be processed. Census currently allows Custom APIs to choose from four operations for each object:
upsert
(most common) - records in the destination can be created or modifiedinsert
- records can only be created in the destination, they cannot be modifiedupdate
- records can only be modified in the destination, they cannot be createdmirror
- records will be created and deleted in the destination as they are added and deleted from the datasetupdate
records in the destination but not insert
them, your Custom API must first check the destination to see if a matching record exists, and tell Census to skip it if it does not exist. Some destination systems may provide APIs like this for you (create this record only if it does not exist) if they have strong enforcement of uniqueness on identifiers.
When it comes to mirror
syncs Census will send separate batches of records. For records that should be created and updated the batch will indicate an operation of upsert
and for records that should be deleted from the destination the operation will be delete
.
insert
, update
, or upsert
sync will include a field that should be used as the identifier for matching source and destination records. This field must be unique and required in both systems (the source data warehouse and the destination SaaS), and it will be provided for every record. Your Custom API will tell Census (via the list_fields
method) which fields can be legally used as identifiers.
https://census-custom-api.yourcompany.example
, you could configure Census to invoke it as https://census-custom-api.yourcompany.example?census_authentication=XoBcsUoFT82wgAcA
and verify all calls include the correct census_authentication
value.
Secrets needed by your Custom API can be stored in several places:
https://census-custom-api.yourcompany.example?census_authentication=XoBcsUoFT82wgAcA&api_key=Ur2NtbfiPuFSkdQp
Authorization
header to every request. In the connection setup screen you will see an optional field:
Custom API Connection setup card with Auth Token field
Authorization: Bearer <your string>
. This avoids the need to add a token to the url. NOTE: Once a token credential has been set it can be changed but not removed.
method
: The name of the method Census is calling on your API. Methods are included in request bodies (instead of as a RESTful-style URL component) so that you can give Census a single URL as the integration point.params
: A JSON object (possibly empty) containing parameters for the methodid
: A unique ID for the request. You must return this same ID in the responsejsonrpc
: This will always be the string "2.0"
result
: A JSON object that is the value you are returning from the method call. Can be empty, depending on the methoderror
: Optional - allows you to return error information to Census in the event of a problem invoking your API. The error
property must not be present if there is a result
id
: The same id
that was passed in to the requestjsonrpc
: This will always be the string "2.0"
https://example.com/census
sync_data
method) within this time, you can use the get_sync_speed
method to tell Census to send data more slowly until you are able to complete within this timeout.
sync_batch
result in the data being actually persisted to the destination system - once you tell Census a record has been synced, Census may never send that record again (if it doesn’t change in the source) and Census has no way to know that it was “lost” from the destination systemget_sync_speed
method.test_connection
and sync_batch
, provide the ability to return application-level error messages. For test_connection
, you can return a high-level error messsage helping the user debug why your Custom API may not be working. sync_batch
requires your Custom API to indicate a success or failure status for each record in the batch - error messages associated with record-level failures will be displayed in the Census Sync History UIX-RateLimit-Limit
header in the responses to our calls against your custom API. For example: if you want to cap requests to your custom service at 100 reqs/second then return X-RateLimit-Limit: 100
as a header in the responses from your service. Whatever value you set here is the limit per second.
NOTE*:* This is different than our operation to fetch the sync speed. In essence these are two rate limiting mechanisms working in tandem. get_sync_speed
is designed to indicate how fast and parallel an individual sync can be while this X-RateLimit-Limit
header is a connection wide limit that acts as a cap to ensure that multiple syncs running simultaneously do not overwhelm the same custom API destination.
can_create_fields
property is set to on_write
. This is useful for objects which can have arbitrary properties, like events. Census allows you to map new fields in the Sync creation UI but it’s on your API implementation to support ingesting and creating these new fields when they are received. Being able to create new fields is a requisite for an object supporting Sync All Properties.
Request
This method has no parameters - the request will always be an empty JSON object
identifer
set to true
, or it cannot be the destination of a Census sync.
A field’s description consists of these required properties:
field_api_name
(string): A unique, unchanging identifier for this fieldlabel
(string): A human-friendly name for the fieldidentifer
(boolean): If true, this field can act as a shared identifier in a Census sync. In order to be used an an identifier, a field must fulfill a few constraints:
required
(boolean): If true, a record cannot be created unless a values is specified for this field. Census will enforce this by requiring a mapping from a data warehouse column to this field before a sync can be performed.createable
(boolean): If true, this field can be populated on record creation in the destination SaaS. This will be true for most fields. An example of a non-creatable field would be something like an auto-populated “Created At” timestamp that you’re not able to write to using the SaaS API.updateable
(boolean): Similar to createable
- if true, this field can be populated when updating an existing record. Generally speaking, if a field is neither createable
nor updateable
, you might consider omitting it entirely from the list_fields
response, as it won’t be usable by Census for any syncs.type
(string): The data type for this field. Census uses this to plan any “type casts” required to translate data from your data warehouse to your SaaS, to warn of invalid or lossy type casts, and will format the data on the wire to your custom destination using this type information. If identifier
is true
, the type must be string
or integer
. See the table below for the full list of types.array
(boolean): If true, this field accepts an array of values instead of a single value. Any type can be used as an array
type, but array
types cannot be identifier
s. Census will require array fields to have a matching array field in the mapped data warehouse column.Census Type | Can Be Identifier | JSON Wire Type | JSON Wire Example | Notes |
---|---|---|---|---|
boolean | No | boolean | true | |
decimal | No | string | "1234.1234" | Fixed-point decimal numbers are sent as strings to avoid loss of precision |
float | No | number | 42.42 | Consider the decimal type instead for numeric data warehouse columns |
integer | Yes | number | 4242 | |
date | No | string | "2021-03-29" | JSON does not have a date type, so dates are ISO 8601 strings |
date_time | No | string | "2021-03-29T16:32:23Z" | JSON does not have a datetime or time type, so date times are ISO 8601 strings. All date_time values will be expressed in UTC |
string | Yes | string | "pepperoni" | String encoding follows the JSON standard |
upsert
: Look for a matching record in the SaaS - if it is present, update its fields with the new values, if not, create it. This is the most commonly used operation.insert
: If a matching record is not present in the SaaS, create it. If it is present, skip syncing this record.update
: If a matching record is present in the SaaS, update it with new field values. If it is not present, do not create it and skip syncing it.maximum_batch_size
: How many records Census should include in each call to sync_batch
(see below). Census may send smaller batches than this, but it will never send larger batches. If your SaaS API has a batch API, you should strongly consider setting this value to match you SaaS’s maximum batch size. If your SaaS does not have a batch import API, we recommend setting this to a relatively low value (under 100) then testing the performance of your custom destination with different batch sizes and increasing the value if needed for increased throughput.maximum_parallel_batches
: How many simultaneous invocations of sync_batch
Census will perform. It’s generally safe to set this to a large number and control your sync speed using the other two variables, but if your underlying infrastructure (web server or function-as-a-service provider) limits the number of parallel calls to your function, you should use this parameter to stay under that limit and avoid queueing at the network layer. NOTE: The maximum allowed value here is 50. If you set a higher number it will be set down to 50.maximum_records_per_second
: How many records (not batches) Census will send to your custom destination per second, across all invocations. This should be matched to your SaaS API’s maximum records per second, possibly with some buffer to allow for measurement error. The actual records per second may be less than this value, depending on maximum_batch_size
, maximum_parallel_batches
, and the average time it takes for your destination to complete one batch.