CSV template to schema conversion API endpoint
The /rpc/csv2schema
endpoint in the Schema Registry API allows you to automatically create an Experience Data Model (XDM) schema using a CSV file as a template. Using this endpoint, you can create templates to bulk-import schema fields and cut down on manual API or UI work.
Getting started
The /rpc/csv2schema
endpoint is part of the . Before continuing, please review the getting started guide for links to related documentation, a guide to reading the sample API calls in this document, and important information regarding required headers that are needed to successfully make calls to any ÃÛ¶¹ÊÓƵ Experience Platform API.
The /rpc/csv2schema
endpoint is part of the remote procedure calls (RPCs) that are supported by the Schema Registry. Unlike other endpoints in the Schema Registry API, RPC endpoints do not require additional headers like Accept
or Content-Type
, and do not use a CONTAINER_ID
. Instead, they must use the /rpc
namespace, as demonstrated in the API calls below.
CSV file requirements
To make use of this endpoint, you must first create a CSV file with appropriate column headers and corresponding values. Some columns are required, while the rest are optional. The table below describes these columns and their role in schema construction.
isIgnored
true
, indicates the field is not ready for API upload and should be ignored.isCustom
fieldGroupId
fieldGroupName
Optional for custom fields not extending existing standard fields. If left blank, system will auto assign name.
Required for standard fields or custom fields extending standard field groups, which is used to query the
fieldGroupId
.fieldPath
fieldGroupName
), set the value to ALL
.displayName
fieldDescription
dataType
If
dataType
is set to object
, either properties
or $ref
needs to also be defined for the same row, but not both.isRequired
isArray
dataType
.isIdentity
isPrimaryIdentity
minimum
maximum
enum
[value1,value2,value3]
).stringPattern
format
minLength
maxLength
properties
dataType
is set to object
and $ref
is not defined. This defines the object body as a JSON string (e.g. {"myField": {"type": "string"}}
).$ref
dataType
is set to object
and properties
is not defined. This defines the $id
of the referenced object for the object type (e.g. https://ns.adobe.com/xdm/context/person
).comment
isIgnored
is set to true
, this column is used to provide the schema’s header information.Refer to the following CSV template to determine how your CSV file should be formatted.
Create an export payload from a CSV file
Once you have set up your CSV template, you can send the file to the /rpc/csv2schema
endpoint and convert it to an export payload.
API format
POST /rpc/csv2schema
Request
The request payload must use form data as its format. The required form fields are shown below.
curl -X POST \
https://platform.adobe.io/data/foundation/schemaregistry/rpc/csv2schema \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-F 'csv-file=@"/Users/userName/Documents/sample-csv-template.csv"' \
-F 'schema-class-id="https://ns.adobe.com/xdm/context/profile"' \
-F 'schema-name="Example Schema"' \
-F 'schema-description="Example schema description."'
csv-file
schema-class-id
$id
of the XDM class that this schema will employ.schema-name
schema-description
Response
A successful response returns an export payload that was generated from the CSV file. The payload takes a form of an array, and each array item is an object that represents a dependent XDM component for the schema. Select the section below to view a full example of an export payload generated from a CSV file.
code language-json |
---|
|
Import the schema payload
After generating the export payload from the CSV file, you can send that payload to the /rpc/import
endpoint to generate the schema.
See the import endpoint guide for details on how to generate schemas from export payloads.