Find a person's records
List every consent record held for one person by an identifier your systems use, and link identifiers you learn later.
Look a person up when you build an account privacy page, a support tool, or before you answer a rights request. One call lists every record held under an identifier, or linked to it.
Before you start#
- A secret key with the scope
subjects:read. Grant it under Scopes on the key in Install. A call without the scope is refused with403 SCOPE_REQUIRED. - The
clientfrom Record consent from your server.
Find the records#
-
Choose the identifier and its type. Write a phone number the way you recorded it, such as E.164.
-
Call
findSubject. The identifier goes in the request body, andsubjectTypeis required.Node.jsJavaScript const found = await client.findSubject('+919846011223', 'PHONE'); for (const record of found.records) { console.log(record.consentId, record.status, record.matchedBy); }Python found = client.find_subject("+919846011223", "PHONE") for record in found["records"]: print(record["consentId"], record["status"], record["matchedBy"])cURLShell curl -X POST https://console.dpconsent.com/consent/sdk/v1/subjects/find \ -H "Authorization: Bearer $PIEDAP_SECRET_KEY" \ -H "Content-Type: application/json" \ -d '{ "subjectId": "+919846011223", "subjectType": "PHONE" }' -
Read
records. They are listed oldest first.
The answer, shortened:
{
"subjectType": "PHONE",
"fingerprint": "41d2c7…",
"records": [
{
"consentId": "cns_3f1c9a7e2b8d4c6fa0e5d1b7c9f2a4e8",
"status": "PARTIAL",
"lawCode": "DPDP",
"test": false,
"erasedOn": null,
"matchedBy": ["PHONE"]
}
]
}matchedBylists the identifier types that matched the record. This record was recorded under a user id and found through its linked phone number.erasedOnis set on records that have been erased. They stay in the list, without identifiers.fingerprintis the subject fingerprint of the identifier you sent.- An empty
recordslist means nothing is held under that identifier. It is not an error.
The calls on a person reach only records of the key's own kind. A test key sees test records, and a live key sees live records.
Link identifiers you learn later#
To make a person's records findable by a new identifier, such as a phone number added to an account, call linkIdentifiers. It needs the scope subjects:link.
const result = await client.linkIdentifiers(
'usr_8f2K1xQz',
'USER_ID',
[{ subjectType: 'PHONE', subjectId: '+919846099887' }],
{ idempotencyKey: 'phone-usr_8f2K1xQz-919846099887' },
);
// { records: 2, added: 2 }from piedap_consent import Identifier
result = client.link_identifiers(
"usr_8f2K1xQz",
"USER_ID",
[Identifier("PHONE", "+919846099887")],
idempotency_key="phone-usr_8f2K1xQz-919846099887",
)
# {"records": 2, "added": 2}curl -X POST https://console.dpconsent.com/consent/sdk/v1/subjects/link \
-H "Authorization: Bearer $PIEDAP_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: phone-usr_8f2K1xQz-919846099887" \
-d '{
"subjectId": "usr_8f2K1xQz",
"subjectType": "USER_ID",
"identifiers": [
{ "subjectType": "PHONE", "subjectId": "+919846099887" }
]
}'- The call links up to five identifiers to every record of the person that is not erased.
recordsis how many records the person has.addedis how many new links were made.- An identifier already linked is skipped, so repeating the call adds nothing.
- Records made later are not linked by this call. Send
identifierswith each new write as well.
What every call on a person shares#
- Each call is written to the project's audit log with the key's name. The identifier itself is never logged.
- These calls share a budget of their own, 60 a minute for each key by default, on top of the key's ordinary budget.
- A request over the budget gets
429with aRetry-Afterheader.
People endpoints lists every field and error.