Use cases
Metadata enables you to extend Uphold entities with your own business data:- External System Integration: Map Uphold entities to your internal records using custom identifiers
- Application State: Store user preferences, feature flags, or configuration per entity
- Analytics & Tracking: Add custom tags, cohort identifiers, or attribution parameters
- Business Logic: Persist data needed for your workflows, compliance, or operational rules
Working with metadata
All metadata operations are performed via dedicated endpoints for each entity type. The endpoints follow a consistent pattern:- Set metadata:
PUT /<api>/<entity>/<entityId>/metadata- Create or replace metadata - Get metadata:
GET /<api>/<entity>/<entityId>/metadata- Retrieve metadata - Update metadata:
PATCH /<api>/<entity>/<entityId>/metadata- Partially update metadata using JSON Patch - Delete metadata:
DELETE /<api>/<entity>/<entityId>/metadata- Remove all metadata
<api>is the API name (e.g.,core)<entity>is the entity type supported within the<api>(e.g.,users,accounts)<entityId>is the unique identifier of the specific entity instance (e.g., user ID, account ID)
Creating metadata
Option 1: During entity creation Include ametadata field when creating entities. Here’s an example of creating a user with metadata:
If metadata creation fails, the entity is still created successfully. The response will include an
errors.metadata property. See Error Handling for details.Retrieving metadata
To fetch the metadata for an entity, use the Get metadata endpoint. Here’s an example of retrieving metadata for the authenticated user:Updating metadata
Option 1: Full replacement To completely replace the existing metadata, use the Set metadata endpoint. Here’s an example of updating the metadata for the authenticated user:Deleting metadata
To remove all metadata associated with an entity, use the Delete metadata endpoint. Here’s an example of deleting the metadata for the authenticated user:Error handling
Size limit exceeded
Metadata payloads have a maximum size of 1024 Unicode characters. If the payload exceeds this limit, a413 Payload Too Large error is returned:
Errors during entity creation
When creating an entity with metadata, if the metadata operation fails, the entity is still created successfully. The response includes anerrors.metadata property describing the issue:
HTTP conditional requests
Metadata endpoints support standard HTTP conditional request headers for concurrency control and efficient caching. These headers are optional but recommended to prevent conflicts and optimize bandwidth.ETag response header:
This header is included in responses to represent the current revision of the metadata.
If-Match request header:
When updating (via PUT or PATCH) or deleting metadata, include this header with the ETag value from a previous response to ensure you’re modifying the expected version. If the ETag does not match the current version, a 412 Precondition Failed error is returned, preventing accidental overwrites.
If-None-Match request header:
When retrieving metadata, include this header with the ETag value from a previous response. If the metadata has not changed, a 304 Not Modified response is returned, saving bandwidth.
Additionally, when creating metadata and you want to ensure none already exists, you can use the If-None-Match header with a value of *. If metadata already exists, a 412 Precondition Failed error will be returned.