> ## Documentation Index
> Fetch the complete documentation index at: https://help.cryptolens.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Data Object

> This method will add a new Data Object to either a license key, product, or your entire account. Please read more about access tokens in Remarks.

This method will add a new [Data Object](/api-reference/generated/DataObjectsIntro) to
either a license key, product, or your entire account. Please read more about access tokens in
[Remarks](/api-reference/generated/AddDataObject#remarks).

This method is accessed in several ways. Each way works in the same way and requires the same permission.
The only difference is the type of parameters. Both cases are listed below:

### Parameters

**Method 1 (general):** [https://api.cryptolens.io/api/data/AddDataObject](https://api.cryptolens.io/api/data/AddDataObject)

| **Parameter** | **Description** | **Remarks** |
| - | - | - |
| Name | The name of the data object. Max 100 characters. | optional, null by default. |
| StringValue | A string value (text) to store. Max 10000 characters. | optional, null by default. |
| IntValue | An int value (int32) to store. | optional, 0 by default. |
| ReferencerType | Indicates if the data object should be added to a license key, a product or the entire user account. User = **0**, Product = **1**, Key = **2**. | optional, user (**=0**) by default. |
| ReferencerId | The id of the Referencer. It can either be an id to a product that you have or to a license key. When ReferencerType is set to User, there is no need to set this value. | optional, 0 by default. |
| CheckForDuplicates | If set to true, this method will check that no other data object with the same name exists. **Note**: setting this to true may affect performance. | optional, false by default. |
| v | Method version. | optional. by default, it's 1. |

**Method 2 (key specific):** [https://api.cryptolens.io/api/data/AddDataObjectToKey](https://api.cryptolens.io/api/data/AddDataObjectToKey)

| **Parameter** | **Description** | **Remarks** |
| - | - | - |
| Name | The name of the data object. Max 100 characters. | optional, null by default. |
| StringValue | A string value (text) to store. Max 10000 characters. | optional, null by default. |
| IntValue | An int value (int32) to store. | optional, 0 by default. |
| ProductId | the product id (=\*\*\[ProductId] \*\*) | required |
| Key | the serial key string | required |
| CheckForDuplicates | If set to true, this method will check that no other data object with the same name exists. **Note**: setting this to true may affect performance. | optional, false by default. |
| v | Method version. | optional. by default, it's 1. |

**Method 3 (machine code specific):** [https://api.cryptolens.io/api/data/AddDataObjectToMachineCode](https://api.cryptolens.io/api/data/AddDataObjectToMachineCode)

| **Parameter** | **Description** | **Remarks** |
| - | - | - |
| Name | The name of the data object. Max 10 characters. | optional, null by default. |
| StringValue | A string value (text) to store. Max 10000 characters. | optional, null by default. |
| IntValue | An int value (int32) to store. | optional, 0 by default. |
| ProductId | the product id (=\*\*\[ProductId] \*\*) | required |
| Key | the serial key string | required |
| MachineCode | the machine code | required |
| CheckForDuplicates | If set to true, this method will check that no other data object with the same name exists. **Note**: setting this to true may affect performance. | optional, false by default. |
| v | Method version. | optional. by default, it's 1. |

### Results

| **Parameter** | **Description** | **Remarks** |
| - | - | - |
| Id | The unique object id for the new data object. | returned if no errors are thrown. |
| Result | This is either **0**(=success) or **1**(=error). | always returned |
| Message | The message that provides additional information about the result. If it's a successful result, **null** will be returned. Otherwise, in case of an error, a short message will be returned describing the error. | always returned. |

### Example results

```text theme={null}
{"id":13,"result":0,"message":null}
```

### Remarks

* When accessing the key specific methods (using productId and the key string), you need to either disable key lock (set it to zero) or set it to a negative number, in the same way you would have done if you would have used [KeyLock](/api-reference/generated/KeyLock). We recommend to set the **KeyLock** to **-1** when creating the access token.

### Errors

| **Error** |
| - |
| Access denied. |
| The input parameters were incorrect. |
| Not enough permission. |
| Not enough permission and/or product not found. |
| Not enough permission and/or key not found. |
| Incorrect 'ReferencerType'. It can either be 0 (for a User), 1 (for a Product) and 2 (for a Key). |
| The 'Name' should have the size of max 100 chars. |
| The 'StringValue' should have the size of max 10000 chars. |
| The limit of the number of data objects was achieved. |
| Not enough permission and/or machine code not found. |
| Data object with the same name already exists. |
