# Custom Attributes

Use the `createProfileCustomAttributes` mutation to **add** or **update** a set of custom attributes associated with the user's profile. These attributes can then trigger/affect different [program rules](https://docs.suggestic.com/console/access-the-main-menu/access-the-main-menu/programs/programs/manage-rules).

### Add and update the custom attributes

Using the `append` argument as `true` the custom attributes sent in the mutation will be added to the existing ones. While using the `append` argument as`false` will overwrite your custom attributes.&#x20;

Use the [`myProfile`](https://docs.suggestic.com/graphql/query/queries/my-profile) query to verify that your attributes were added or updated correctly.

See [these examples](#examples).

### Updating Custom Attributes

## Available Arguments

| **Argument** | **Required?** | **Type**                                             |                                                                                       **Description**                                                                                      |
| ------------ | :-----------: | ---------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| `attributes` |      True     | \[[ProfileCustomAttribute](#profilecustomattribute)] |                                                             Object that includes all the custom attributes to add in the query.                                                            |
| `append`     |     False     | Boolean                                              | **True** if it is required to add new custom attributes to the existing ones. By default, this argument is sent as **False.**, therefore the custom attributes values will be overwritten. |

## ProfileCustomAttribute

### Available Fields

| **Field**   | **Type**       | **Description**                                                           |
| ----------- | -------------- | ------------------------------------------------------------------------- |
| `name`      | String!        | attribute name                                                            |
| `dataType`  | AttrDataType!  | attribute data type: `STRING, INT, FLOAT, BOOLEAN`                        |
| `value`     | GenericScalar! | Attribute value which can be String, Boolean, Int, Float, List or Object. |
| `category`  | String         | category name                                                             |
| `timestamp` | Float          | timestamp in float format                                                 |

## Available Fields

| **Field name** |  **Type**  |                                                                    **Description**                                                                   |
| :------------: | :--------: | :--------------------------------------------------------------------------------------------------------------------------------------------------: |
|    `success`   |   Boolean  |                            **True** if the custom attribute list has updated successfully. Otherwise, it returns **False**                           |
|    `errors`    | Error Type | <p>It retrives an error in case the custom attribute cannot be added. Sent the error field as follows:<br><code>errors { field messages }</code></p> |

## Examples

### Create custom attributes

The following example will create custom attributes based on the values sent in the object.&#x20;

{% tabs %}
{% tab title="Query" %}

```graphql
mutation {
  createProfileCustomAttributes(
    attributes: [
      {
        name: "Carbohydrate Metabolism",
        dataType: STRING,
        value: "Slow"
        category: "Genetics"
        timestamp: 507482179.234
      },
      {
        name: "Gluten Sensitivity",
        dataType: INT,
        value: 1
        category: "Allergen"
        timestamp: 507482179.234
      },
      {
        name: "Lactose Tolerance",
        dataType: FLOAT,
        value: 1.4
        category: "Genetics"
        timestamp: 507482179.234
    	},
      {
        name: "Fiber Need",
        dataType: BOOLEAN,
        value: true
        category: "Food Boost"
        timestamp: 507482179.234
      }
    ]) {
    success
    errors {
      field
      messages
    }
  }
}

```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "createProfileCustomAttributes": {
      "success": true,
      "errors": []
    }
  }
}
```

{% endtab %}
{% endtabs %}

Overwrite your custom attributes by sending different values, therefore, all the attributes created before are replaced with the new ones. See the example below:

![](https://920729701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwqSnBDpAb6mFZYLsuB%2Fuploads%2FROzAaCEzy5SQjsNJDhNT%2FCustomAttributes.gif?alt=media\&token=ff499eb6-5dc1-4717-9597-5176766113c0)

### Update the existing custom attributes

Use the `append` argument to update your existing attributes:

{% tabs %}
{% tab title="Request" %}

```graphql
mutation {
  createProfileCustomAttributes(
    append: true
    attributes: [
    {
        name: "Lactose Tolerance",
        dataType: FLOAT,
        value: 1.4
        category: "Genetics"
        timestamp: 507482179.234
    	}
    ]) {
    success
    errors {
      field
      messages
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "createProfileCustomAttributes": {
      "success": true,
      "errors": []
    }
  }
}
```

{% endtab %}
{% endtabs %}

Based on the previous example, the new attribute will be added to the current one:

![](https://920729701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwqSnBDpAb6mFZYLsuB%2Fuploads%2FLZzx0H27xAfwpn6jjQUk%2FCustomAttributesOverwrrite.gif?alt=media\&token=a9b79c1a-3da6-4951-94a1-0186d1ecb60f)
