# GraphQL API Examples

For GraphiQL Playground go to <https://apis.objectsgrid.com/playground>

### Create an Access Token example

GraphiQL Query and Headers sections:

```graphql
mutation CreateAccessToken{
  createUserAccountAccessToken(input: {
    grant_type: "urn:ietf:params:oauth:grant-type:token-exchange"
    subject_token: "your id token here, use https://admin.objectsgrid.com/google_token.html to get one"
    subject_token_type: "urn:ietf:params:oauth:token-type:id_token"
    client_id: "your organization account id org-???-????"
  }){
    access_token
    token_type
    expires_in
    refresh_token
  }
}
```

```graphql
{
  "X-ObjectsGrid-Accesspoint": "EU"
}
```

You should get back:

```graphql
{
  "data": {
    "createUserAccountAccessToken": {
      "access_token": "newly created access token for you to use to call all OG APIs",
      "token_type": "Bearer",
      "expires_in": 14399,
      "refresh_token": "newly created refresh token for you"
    }
  }
```

### Create Generic Object

GraphiQL Query and Headers sections:

```graphql
mutation CreateGenericObject{
  createGenericObject(
    input: {
    objectID: "yourObjectID",
    namespace: "yourNamespace",
    objectType: "yourObjectType"
})
  {
    id,
    objectID,
    namespace,
    objectType,
    meta{
      objectVersion
      createdAt,
      createdBy
    }
  }
}
```

```graphql
{
  "X-ObjectsGrid-Accesspoint": "EU",
  "Authorization": "Bearer your_access_token_obtained_above"
}
```

You should get back something close to:

```json
{
  "data": {
    "createGenericObject": {
      "id": "e4955322-d835-4b25-93c3-133fca2ba9f7",
      "objectID": "object-10003",
      "namespace": "namespace",
      "objectType": "product",
      "meta": {
        "objectVersion": 1744788743359810,
        "createdAt": "2025-04-16T07:32:23.093716032Z",
        "createdBy": "56228ff2-1034-43b0-8c66-9fb1bfdb1910"
      }
    }
  }
}
```

### Retrieve Generic Object

GraphiQL Query and Headers sections:

```graphql
query RetrieveGenericObject {
  genericObject(id: "e4955322-d835-4b25-93c3-133fca2ba999"){
    id,
    objectID,
    namespace,
    objectType
  }
}
```

```graphql
{
  "X-ObjectsGrid-Accesspoint": "EU",
  "Authorization": "Bearer your_access_token_obtained_above"
}
```

You should get back something close to:

```json
{
  "data": {
    "genericObject": {
      "id": "e4955322-d835-4b25-93c3-133fca2ba999",
      "objectID": "object-10003",
      "namespace": "namespace",
      "objectType": "product"
    }
  }
}
```

###

### Update a Generic Object

GraphiQL Query and Headers sections:

```graphql
mutation UpdateGenericObject {
  updateGenericObject(input: {
    id: "e4955322-d835-4b25-93c3-133fca2ba999",
    objectID: "object-10003",
    namespace: "namespace",
    objectType: "product",
    stringAttributes: [
      {
        name: "name1",
        val: "val1"
      }
    ]
  }){
    id,
    objectID,
    namespace,
    objectType
    stringAttributes{
      name,
      val
    }
  }
}
```

```graphql
{
  "X-ObjectsGrid-Accesspoint": "EU",
  "Authorization": "Bearer your_access_token_obtained_above"
}
```

You should get back something close to:

```json
{
  "data": {
    "updateGenericObject": {
      "id": "e4955322-d835-4b25-93c3-133fca2ba999",
      "objectID": "object-10003",
      "namespace": "namespace",
      "objectType": "product",
      "stringAttributes": [
        {
          "name": "name1",
          "val": "val1"
        }
      ]
    }
  }
}
```

### Delete Generic Object

GraphiQL Query and Headers sections:

```graphql
mutation DeleteGenericObject {
  deleteGenericObject(id: "e4955322-d835-4b25-93c3-133fca2ba999")
}
```

```graphql
{
  "X-ObjectsGrid-Accesspoint": "EU",
  "Authorization": "Bearer your_access_token_obtained_above"
}
```

You should get back:

```json
{
  "data": {
    "deleteGenericObject": true
  }
}
```

###

### List Generic Objects

GraphiQL Query and Headers sections:

```graphql
query listGenericObjects {
  genericObjects(from: 1, size: 5) {
    id
    namespace
    stringAttributes{
      name
      val
    }
  }
}
```

```graphql
{
  "X-ObjectsGrid-Accesspoint": "EU",
  "Authorization": "Bearer your_access_token_obtained_above"
}
```

You should get back:

```graphql
{
  "data": {
    "genericObjects": [
      {
        "id": "095567a3-bf9b-4d58-88b9-becf65725902",
        "namespace": "com.objectsgrid.test",
        "stringAttributes": [
          {
            "name": "Attr1",
            "val": "val1"
          },
          {
            "name": "Attr2",
            "val": "val2"
          }
        ]
      },
      {
        "id": "61af808a-9bac-4593-b73e-cf1a2e0d189b",
        "namespace": "com.objectsgrid.test",
        "stringAttributes": [
          {
            "name": "Attr1",
            "val": "val1"
          },
          {
            "name": "Attr2",
            "val": "val2"
          }
        ]
      },
      {
        "id": "4cc66522-8a9f-4e45-b7e2-d0908158f015",
        "namespace": "com.objectsgrid.test",
        "stringAttributes": [
          {
            "name": "Attr1",
            "val": "val1"
          },
          {
            "name": "Attr2",
            "val": "val2"
          }
        ]
      }
    ]
  }
}
```

### Create EnumStringLocalized

GraphiQL Query and Headers sections:

<pre class="language-graphql"><code class="lang-graphql"><strong>mutation CreateEnumStringLocalized {
</strong>  createEnumStringLocalized(
    input:{
      id: "id234",
      description: "description",
      disabled: false,
      values:[
      {
        key: "key1",
        val: [
          {
            language: "en",
            value: "val en"
          },
          {
            language: "de",
            value: "val de"
          }
        ],
        order: 1
      },
      {
        key: "key2",
        val: [
          {
            language: "en",
            value: "val en"
          },
          {
            language: "de",
            value: "val de"
          }
        ],
        order: 2
      }
    ],
  tags: [
    {
      name: "Attr1",
      val: "val1"
    },
    {
      name: "Attr2",
      val: "val2"
    }
  ]
}
  ){
    id
    description
    values{
      key
      val{
        language
        value
      }
    }
    disabled
    tags{
      name
      val
    }
    meta{
      createdBy
      createdAt
      objectType
    }
  }
}
</code></pre>

###

```graphql
{
  "X-ObjectsGrid-Accesspoint": "EU",
  "Authorization": "Bearer your_access_token_obtained_above"
}
```

###

### Retrieve EnumStringLocalized

GraphiQL Query and Headers sections:

```graphql
query RetrieveEnumStringLocalized {
  enumStringLocalizedByID(id: "id234"){
        id
    description
    values{
      key
      val{
        language
        value
      }
    }
    disabled
    tags{
      name
      val
    }
    meta{
      createdBy
      createdAt
      objectType
    }
  }
    
}
```

###

```json
{
  "X-ObjectsGrid-Accesspoint": "EU",
  "Authorization": "Bearer your_access_token_obtained_above"
}
```

### Update EnumStringLocalized

GraphiQL Query and Headers sections:

```graphql
mutation UpdateEnumStringLocalized {
  updateEnumStringLocalized(
    input:{
      id: "id234",
      description: "description UPDATED",
      disabled: false,
      values:[
      {
        key: "key1",
        val: [
          {
            language: "en",
            value: "val en"
          },
          {
            language: "de",
            value: "val de"
          }
        ],
        order: 1
      },
      {
        key: "key2",
        val: [
          {
            language: "en",
            value: "val en"
          },
          {
            language: "de",
            value: "val de"
          }
        ],
        order: 2
      }
    ],
  tags: [
    {
      name: "Attr1",
      val: "val1"
    },
    {
      name: "Attr2",
      val: "val2"
    }
  ]
}
  ){
    id
    description
    values{
      key
      val{
        language
        value
      }
    }
    disabled
    tags{
      name
      val
    }
    meta{
      createdBy
      createdAt
      objectType
    }
  }
}


```

```graphql
{
  "X-ObjectsGrid-Accesspoint": "EU",
  "Authorization": "Bearer your_access_token_obtained_above"
}
```

###

### Delete EnumStringLocalized

GraphiQL Query and Headers sections:

```graphql
mutation DeleteEnumStringLocalized {
  deleteEnumStringLocalized(id: "id234")
}
```

```
{
  "X-ObjectsGrid-Accesspoint": "EU",
  "Authorization": "Bearer your_access_token_obtained_above"
}
```

You should get back "true":

```graphql
{
  "data": {
    "deleteEnumStringLocalized": true
  }
}
```

###

### List Enums IDs

GraphiQL Query and Headers sections:

```graphql
query listEnums{
  enums
}
```

```graphql
{
  "X-ObjectsGrid-Accesspoint": "EU",
  "Authorization": "Bearer your_access_token_obtained_above"
}
```

You should get back an array of Enums IDs:

```json
{
  "data": {
    "enums": [
      "id123",
      "id124",
      "id125",
      "myEnum1"
    ]
  }
}
```


---

# 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://docs.objectsgrid.com/documentation/usage-guide/graphql-api-examples.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.
