Documentation Center

create<TYPE> mutation

Use the createType GraphQL mutation to create new entities.

Mutation syntax

The following code illustrates required format for the GraphQL request, followed by a description of the input values:

mutation {
  createTYPE([parentIdentity: {
                 namespace: "NAMESPACE",
                 id: "IDENTIFIER",
                 type: "TYPE"
             },
             ]
             input: {
                INPUT_FIELD_1: INPUT_VALUE_1
                INPUT_FIELD_2: INPUT_VALUE_2
                INPUT_FIELD_n: INPUT_VALUE_n
													} )
   {
       RESPONSE_FIELD_1
       RESPONSE_FIELD_2
       RESPONSE_FIELD_n
   }
}

Fields and inputs

createTYPE
The operation to be performed by the mutation (create) and the type of entity to be created. The TYPE is the entity type and matches the TYPE value in the identity section.
parentIdentity
In the parentIdentity section, identify either the namespace root ID or a parent folder or category of the entity being created.
namespace
Where NAMESPACE is that of the external entity.
id
Where IDENTIFIER is the unique identifier provided by the external system.
type
Where TYPE refers to the external entity type.
localId
Where LOCAL_ID can be either a Publication ID or a locale string, such as 'en' or 'sv-se', which identifies a locale-specific variant of the entity.
input
The input object includes property-value pairs that define the entity to be created, where:
INPUT_FIELD_1 to n
The property to be defined for the new entity.
The GraphQL type definition for the current entity type specifies which fields are available as input.
INPUT_VALUE_1 to n
The input data for the entity.
Depending on the field type and definition, the data can be a string, integer, float, boolean, or nested structure.
Response fields
(Optional) Fields at the end of the request identify data that you want to return in the response following a successful create operation.
The GraphQL type definition for the current entity type specifies which fields are available in a response.

Example request and response

The first sample code block illustrates a request to to create a new entity of the type "Contact". The second code block illustrates the corresponding response with a confirmation of the new entity's identity.

RequestResponse
mutation {
  createContact(
    parentIdentity: {
      namespace: "ExampleCRM"
      id:"root"
    }
    input: {
      firstName: "John"
      lastName: "Smith"
      email: "jsmith@company.com"
      phone: "+441234567890"
    }
  ) {
    identity {
      namespace
      id
      type
    } 
  }
}
{
  "data": {
    "createContact": {
      "identity": {
        "namespace": "salesforce",
        "id": "0033Y00002pvAjuQAE",
        "type": "Contact"
      }
    }
  }
}