# Property Group Mutation

### Mutation Types

{% hint style="info" %}
**upsertPropertyGroup**: Mutation is responsible for inserting or updating a specific register, the operation insert or update is defined by **`externalId`**, in case this property was imported previously, this mutation will updated the resource, otherwise will create the property.
{% endhint %}

```graphql
type Mutation {
  upsertPropertyGroup(propertyGroup: PropertyGroupInput!): PropertyGroup!
}
```

Here are details on the capabilities of different mutations

* The `upsertPropertyGroup` the mutation is used to create or update a property group in the EverReal system and property added to the system cannot be modified by Everreal and if needs to be modified it should be done via the same endpoint itself.

### Schema Definition

{% hint style="warning" %}
&#x20;items with **!** notation are required
{% endhint %}

```graphql
input PropertyGroupInput {
  name: String
  externalPropertyGroupId: String!
  descriptions: PropertyGroupDescriptionInput
}


input PropertyGroupDescriptionInput {
  object: String
  amenities: String
  location: String
  other: String
}

```

> `externalPropertyGroupId` is required field, this is the `key` or the `id` which is used by the 3d party system(data synchronize between 3rd party)&#x20;

Below we are providing a full example how to create or update a property, all this information is not required, only the ones that was using **!** notation previously.

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

```graphql
mutation {
  upsertPropertyGroup(
    propertyGroup: {
        name: "Ray - PG1"
        externalPropertyGroupId: "RPG-1"
        descriptions:{
            object: "Sample - Object"
            amenities: "Sample - Amenities"
            location: "Sample - Location"
            other: "Sample - Other"
        }
    }
  ) { id }
}
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer ....");
myHeaders.append("Content-Type", "application/json");

var graphql = JSON.stringify({
  query: "mutation {\n  upsertPropertyGroup(\n    propertyGroup: {\n        name: \"Ray - PG1\"\n        externalPropertyGroupId: \"RPG-1\"\n        descriptions:{\n            object: \"Sample - Object\"\n            amenities: \"Sample - Amenities\"\n            location: \"Sample - Location\"\n            other: \"Sample - Other\"\n        }\n    }\n  ) { id }\n}",
  variables: {}
})
var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: graphql,
  redirect: 'follow'
};

fetch("https://acme-qa.everreal-dev.co/api/reporting/graphql", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api-docs.everreal.co/endpoints/property-groups/property-group-mutation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
