---
schema_version: "1"
id: a9d4756dc540cda2ced08efd08bc3e6b0d575bfd32ff62a92b7b8bc731695bef
title: Create a Record
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/graphql-api/graphql/guides/mutations/mutations-create.md
canonical_url: https://developer.salesforce.com/docs/platform/graphql/guide/mutations-create.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 5003c9cd6631c6ee1d9ec40bde7b91eef4d6261ffb6b6a25801d2496f623789d
products:
  - GraphQL API
---
# Create a Record

| AVAILABLE API VERSION               |
| ----------------------------------- |
| Beta v59.0–65.0                     |
| Generally available v66.0 and later |

Use `mutations` to create a record. Within `mutations`, the [`RecordCreate` field](https://developer.salesforce.com/docs/platform/graphql/guide/mutations-schema.md) enables you to create all object types your Salesforce user has access to. Only [objects supported by UI API](https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_get_started_supported_objects.htm) are available for mutations. For create mutations, the context user must have read access to the new record.

## Example Account Create Request

To create a record, use `RecordCreate` with field values for the record you want to create.

A response is returned when record creation is successful. To define the fields you want the response body to return, use the `Record` field. You can return the `Id` and selected fields from your record creation.

For example, create an account with the required name field.

```
mutation AccountExample{
  uiapi {
    AccountCreate(input: {
      Account: {
        Name: "Trailblazer Express"
      }
    }) {
      Record {
        Id
        Name {
          value
        }
      }
    }
  }
}
```

## Example Response on Account Record Creation

The response body returns the fields you request under `Record`.

```
{
  "data": {
    "uiapi": {
      "AccountCreate": {
        "Record": {
          "Id": "001RM000005fdQuYAI",
          "Name": {
            "value": "Trailblazer Express"
          }
        }
      }
    }
  },
  "errors": []
}
```

## Example Child Contact Create Request

Given the account ID returned by the account record creation, create an associated contact for that account.
This example uses the record ID from the example, `001RM000005fdQuYAI`. Replace the account ID with your own.

```
mutation ContactExample{
  uiapi {
    ContactCreate(input: {
      Contact: {
        FirstName: "Appy"
        LastName: "Bobcat"
        Email: "appy@example.com"
        AccountId: "001RM000005fdQuYAI"
      }
    }) {
      Record {
        Id
        Name {
          value
        }
        Email {
          value
        }
      }
    }
  }
}
```

## Example Response on Child Record Creation

The response body returns the fields you request under `Record`.

```
{
  "data": {
    "uiapi": {
      "ContactCreate": {
        "Record": {
          "Id": "003RM000008B7H0YAK",
          "Name": {
            "value": "Appy Bobcat"
          },
          "Email": {
            "value": "appy@example.com"
          }
        }
      }
    }
  },
  "errors": []
}
```

## Record Creation Guidelines

Consider these guidelines for creating a record.

- For compound fields, use the constituent fields. For example use `FirstName` and `LastName` instead of `Name`.
- For numerical field values, such as integers or currency, use the raw values. For example, use `80000` instead of `80,000` and don’t include currency symbols.
- Sending a create request with field values that don’t match the supported format returns a [`ValidationError`](https://developer.salesforce.com/docs/platform/graphql/query/query-status.md). Use the appropriate format for the field, such as [`YYYY-MM-DD` for date fields](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm).
- Sending a create request with duplicate values can return a `DataFetchingException` error. Review your [duplicate rules](https://help.salesforce.com/s/articleView?id=sales.duplicate_rules_create.htm) and make sure you’re not creating a duplicate record.

## See Also

[Send Mutation Requests](https://developer.salesforce.com/docs/platform/graphql/guide/mutations-use.md)
