Create a schema

Each new Identity Cloud customer is issued a single entity type (user) that comes with a reasonably large number of predefined attributes. Of course, that leads to an obvious question: is one entity type really going to be enough for you? 

To be honest, that question is largely irrelevant. After all, if one entity type isn’t going to be enough for you then you can simply create as many additional entity types as you need. In this section of the documentation, we’ll walk you through the process of creating a new entity type by:

  • Copying an existing schema. Keep in mind that this process creates an exact replica of the existing entity type’s schema: you now have a second entity type that contains the same attributes, validations, and transformations as found in the “base” entity type. However, new entity type doesn't contain any of the data stored in the existing entity type. Your new entity type will consist of a schema and no data. We’re copying the schema (i.e., the database blueprint) and not the entire database.

  • Importing a JSON file containing definitions for all attributes to be included in the new entity type. Importing a JSON file gives you the ability to create a truly custom entity type in a single operation. At the same time, however, it does require you to create a JSON file from scratch, something that can be a bit challenging if your new entity type includes objects and/or plurals.

Regardless of how you initially create your new entity type, you can change that entity type at any time, adding attributes, deleting attributes, modifying validations and transformations, and so on.

Create a schema by using JSON

Creating a new entity type by copying an existing entity type is a good way to go …. provided that you want the new entity type to have the exact same format as one of your existing entity types. But what if your new entity type needs to be different from all of your existing entity types? In that case, you might want to use JSON (JavaScript Object Notation) to create the schema for the new entity type, then use Registration Builder to either paste in or import that schema.

We won’t go over the ins and outs of creating a JSON representation of an entity type schema in this documentation; that’s something you’re highly unlikely to do in the Console anyway. Suffice to say that a very simple JSON schema (one that only includes two minimally-defined attributes: name and description) will look similar to this:

[{
    "name": "name",
    "type": "string",
    "case-sensitive": false
}, {
    "name": "description",
    "type": "string",
    "length": 1000,
    "case-sensitive": false
 }]

👍

If you’re new to creating attributes by using JSON, you might want to use the /config/{appId}/entityTypes/{entityType}/attributes/{attribute} operation and the GET method to return the JSON description for an attribute or two. You can then use those JSON descriptions as a template for creating your own attributes.


We should also add that, even though we only defined two attributes in our sample JSON file, the resulting entity type will have six attributes:

  • name
  • description
  • id
  • uuid
  • created
  • lastUpdated

That's because the last four attributes in the list (id, uuid, created, and lastUpdated) are system-generated attributes automatically added to all new entity types. Furthermore, these attributes can’t be copied, deleted, or modified; notice how there’s no way to access any of those functions in Console:

As soon as you have a valid JSON file you can create a new entity type by completing the following procedure:

  1. Click Create and then click Entity Type:

  2. In the subsequent dialog box, click Import JSON:

That brings up the following dialog:

This dialog offers several options for copying your JSON file. To begin with, you can simply drag and drop your file onto the dialog; the JSON will be copied from the file and displayed onscreen:

If dragging and dropping isn’t really your thing then click Upload a File and select the file containing your JSON:

And if you don’t like that option either, just click Paste in your own JSON to display this dialog:

You can then paste in the code copied from your JSON file.


📘

You can also type JSON directly into the dialog box. To be honest, the dialog box probably isn’t the best JSON editor ever made. However, the dialog box does do one thing quite nicely: it validates your JSON before it lets you proceed. In fact, the Next button won’t activate unless you’ve entered a valid JSON string. The dialog can’t tell you if the attribute is correct (i.e., that you've entered all the required properties and property values). But it will catch any JSON-related errors.


After you’ve entered a valid JSON string, click Next. To create your new entity type, enter a name in the Name field and then click Save:

Just like that, you’ve created a new entity type.


Did this page help you?