---
updatedAt: 2025-09-16T21:19:13.000Z
agentTools:
  projectIndex: https://developer.ironcladapp.com/llms.txt
---

# Create a Record

```node Node
require('dotenv').config();
const axios = require('axios').default;
const dateFormat = require('dateformat');

// Be sure to store your API securely!
const apiKey = process.env.API_KEY;

// Your host URL may vary based on the implementation.
const hostUrl = (process.env.HOST_URL ? process.env.HOST_URL : 'ironcladapp');
const apiUrl = `https://${hostUrl}.com/public/api/v1`;

const recordPayload = () => {
  // Using the current date for example purposes.
  const now = Date();

  // The date needs to be formatted for the API.
  const formattedDate = dateFormat(now, `yyyy-mm-dd'T'HH:mm:ssp`);

  return {
    type: 'contract',
    name: 'My API Generated Record',
    properties: {
      agreementDate: {
        type: 'date',
        value: formattedDate,
      },
      counterpartyName: {
        type: 'string',
        value: 'Example Company',
      },
    },
  };
};

// Create the record.
const createRecord = async () => {
  const createRecordUrl = `${apiUrl}/records`;
  const record = recordPayload();
  const response = await axios.post(
    createRecordUrl,
    JSON.stringify(record),
    {
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${apiKey}`,
      },
    },
  );
  return response;
};

createRecord()
  .then((response) => console.log(
    `Created record with ID: ${response.data.id}`,
  ))
  .catch((err) => console.log(err));

```

```json Response Example
{"success":true}
```

# Add Dependencies

<!-- node@1-3 -->

This example uses the `dotenv`, `axios`, and `dateformat` Node libraries.

# Configure API Options

<!-- node@5-10 -->

We have our API token stored in a `.env` file (there are better options out there and we recommend following best practices) and we also set up the API URL relevant to our provisioned account environment.

# Generate Payload

<!-- node@12-33 -->

For this example, we are using the minimal properties needed to create a record. Continue to the next step for more information on what all this function entails.

# Format Agreement Date

<!-- node@13-17 -->

The `records` endpoint requires a specific date format to be processed. Here, we use the `dateFormat` library to format the current date and time.

# Specify Record Type

<!-- node@20-20 -->

Every Ironclad Record created needs to be associated with a Record Type. In this example, we specify 'contract' as it exists within the targeted Ironclad Account.

To view available records types for your Ironclad Account, retrieve the schema using [this API route](https://developer.ironcladapp.com/reference/list-all-records-metadata).

# Specify Record Name

<!-- node@21-21 -->

The name of the Record is what is shown on the Repository page when logged into Ironclad. By default, many Ironclad Workflows will default to a format of: _Record Type Display Name_ with _Company Name (counterpartyName)_. So, following this naming convention may lead to better Record naming consistency.

# Specify Properties

<!-- node@22-31 -->

The properties object contains metadata that is added to the Record. The keys `agreementDate` and `counterpartyName` must be present on all Records.

You can find available properties within your Ironclad using [this API route](https://developer.ironcladapp.com).

# Create API Call Function

<!-- node@35-50 -->

Now that we have the payload ready, do a `POST` to the `/records` endpoint with the payload as JSON and required headers.

# Initialize and Handle API Call

<!-- node@52-56 -->

We call the `createRecord` method, check that we receive a successful response, and then log the newly created Record ID. Grabbing the ID can be great when you need to attach a document after the Record has been created using the [Create an Attachment on a Record](https://developer.ironcladapp.com/reference/create-an-attachment-on-a-record) API.

Catching the error is always a good idea in case you need to notify a team member or need to retry at a later time.