The three write formats
The first two formats fail if they do not find exactly one record. The third format lets you choose what happens when no record or more than one record matches, and can create the record for you. With both matching formats, the matching attribute does not have to be unique, but we recommend a unique attribute, such as a domain, an email address or an ID from your own system.
All three formats are write-only. Responses always return the resolved record as
target_object and target_record_id.
The target record reference format
target_object stays alongside target_record_reference, exactly as in the other two formats.
Matching a record
match takes exactly one attribute, identified by its slug or ID, and exactly one value. You can write the value on its own or as an array with one element. Both of these are the same:
if_multiple_matches decides what happens when the value matches more than one record.
Two or more keys in match, or two or more values for one key, are rejected with a 400.
When no record matches
erroris the default. The request fails with a400naming the value that was not found. This is how the other two write formats behave.createcreates the record from thematchvalue and, if you supply it,create.ignoredrops the value and lets the rest of the request succeed. Use it when the link is nice to have but the record itself must be written either way.
When several records match
erroris the default. More than one match fails the request with a400, instead of picking a record for you.match_alllinks every matching record, up to 50 records per value. Above that, the request fails and you should use a more specific value or reference the records by ID.
match_all only applies to multiselect (“many”) attributes. On a single-value attribute, more than one match always fails with a 400, so that Attio never has to choose between them.
Creating the referenced record
create carries the values the new record is created with. The match value is added automatically, so do not repeat it:
createis ignored unlessif_unmatchedis"create".- Creation is one level deep. The values in
createcannot themselves create further records, so a referenced record can be created, but the records it references must already exist. - Records that already match are never updated.
createapplies only when nothing matches. - Identical references in one request are merged, so the record is created once even if several attributes point at it. If the same reference appears twice with different
createvalues, the request fails.
Order of writes and retries
Referenced records are not created atomically with the main record. Attio creates them first, before it writes the main record, so that they exist when the main record references them. If the main write then fails, the referenced records that were created are kept. This means that it is safe to retry a request that failed, for example with a5xx error. On the retry, match finds the records that were created on the first attempt and links them, so no duplicates are created. The retry does not update those records, so values in create that differ from the first attempt are not applied.
Limits
The 10 records per request are counted after identical references are merged.
Required scopes
Creating referenced records writes to records of another object, so the token needsrecord_permission:read-write and object_configuration:read on top of the scopes the endpoint itself requires. Without them the request fails with a 403. Matching without creating does not need the write scope.
Rate limits
Every referenced record that Attio creates counts as one more write request. See handling rate limits for how this affects your budget.Supported endpoints
Thetarget_record_reference format is accepted on these endpoints only:
- Create a record and upsert a record
- Update a record, both append and overwrite
- The equivalent activity record endpoints