Update the metadata of an email account
const url = 'https://api.clearance.rest/emails/accounts/example';const options = { method: 'PATCH', headers: {'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json'}, body: '{"metadata":{"additionalProperty":"example"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://api.clearance.rest/emails/accounts/example \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --data '{ "metadata": { "additionalProperty": "example" } }'JSON Merge Patch (RFC 7396) on the account’s metadata: keys set to null are removed, arrays are replaced. Send If-Match: "<metadata_version>" to update only if nobody changed it in between; otherwise the response is 412 metadata_version_mismatch and error.details.current_version holds the current version. Limits: 16 KB, 5 levels, keys up to 64 characters.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Email address (URL-encoded).
Header Parameters
Section titled “Header Parameters”Metadata version from the last read (the metadata_version field or the ETag header), for example "3". The update fails with 412 and error.details.current_version when it no longer matches; * matches any version. Without the header the update is unconditional.
Request Bodyrequired
Section titled “Request Bodyrequired”JSON Merge Patch (RFC 7396) of the metadata: keys set to null are removed, arrays are replaced.
object
Free-form JSON object (at most 16 KB, 5 levels deep, keys up to 64 characters).
object
Examplegenerated
{ "metadata": { "additionalProperty": "example" }}Responses
Section titled “Responses”Default Response
object
A Gmail, Outlook or Cloudflare address connected to the project.
object
Provider of an email account.
CONNECTED: notifications are active. RENEWING: the subscription expired or is not set up yet and will be renewed automatically. REAUTH_REQUIRED: the last token refresh or sync failed; the owner may need to authorize again. Cloudflare addresses are always CONNECTED.
Whether the mailbox granted the permission needed for mark_as_read.
Free-form JSON object (at most 16 KB, 5 levels deep, keys up to 64 characters).
object
Increases on every metadata change; use it in If-Match.
UTC timestamp (ISO 8601).
UTC timestamp (ISO 8601).
Example
{ "success": true, "account": { "email_provider": "gmail", "status": "CONNECTED" }}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}Default Response
The If-Match version does not match the current metadata version.
object
object
object
The current metadata_version; read the resource again and retry.
Example
{ "success": false, "error": { "code": "metadata_version_mismatch" }}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}