# Mutations / Host

# Host

**Mutation**
## applyHostChange — Returns [HostChange](/documentation/Objects/Host#HostChange)

**Scopes required:** manage_host_changes

| Arguments | Type | Description |
| --- | --- | --- |
| id | [ID!](/documentation/Types/UUID#UUID) | The ID of the host change to apply |
| autoProcessQueue | *Boolean* | Whether to automatically process the queue after applying the change, defaults to true |
| applyTo | [ID](/documentation/Types/UUID#UUID) | The item to apply the change to, if not specified it will be automatically matched |

**Example Mutation**

```graphql
mutation ApplyHostChange($id: ID!) {
    applyHostChange(id: $id) {
        id,
        clientId,
        applyTo,
        rawMatch,
        change
    }
}

# Example variables
{
    "id": "<ID>"
}
```

**Mutation**
## bulkApplyHostChanges — Returns *boolean*

**Scopes required:** manage_host_changes

Apply a list of host changes in bulk from multiple connections. Will return false if any of the changes failed to apply

| Arguments | Type | Description |
| --- | --- | --- |
| changes | [[ApplyHostChangeInput!]!](/documentation/Inputs/Host#ApplyHostChangeInput) | The changes to apply |
| allowCreation | *Boolean* | Whether to allow the creation of items encountered in the list of `changes`. The usage of this flag will override the automatic settings of the connection for the duration of the `changes` |
| autoProcessQueue | *Boolean* | Whether to automatically process the queue after applying the change, defaults to true |

**Example Mutation**

```graphql
mutation BulkApplyHostChanges($changes: [ApplyHostChangeInput!]!) {
    bulkApplyHostChanges(changes: $changes)
}

# Example variables
{
    "changes": [
        {
            "id": "<ID>"
        }
    ]
}
```

**Mutation**
## bulkIgnoreHostChanges — Returns *boolean*

**Scopes required:** manage_host_changes

| Arguments | Type | Description |
| --- | --- | --- |
| ids | [[ID!]!](/documentation/Types/UUID#UUID) | The ID of the host change to apply |
| autoProcessQueue | *Boolean* | Whether to automatically process the queue after applying the change, defaults to true |

**Example Mutation**

```graphql
mutation BulkIgnoreHostChanges($ids: [ID!]!) {
    bulkIgnoreHostChanges(ids: $ids)
}

# Example variables
{
    "ids": [
        "<IDS>"
    ]
}
```

**Mutation**
## createHostConnection — Returns [HostConnection](/documentation/Objects/Host#HostConnection)

**Scopes required:** modify_host_connections

| Arguments | Type | Description |
| --- | --- | --- |
| type | [HostConnectionTypeEnum!](/documentation/Enums/Host#HostConnectionTypeEnum) | The type of host connection this is |
| outlet | [ID!](/documentation/Types/UUID#UUID) | The ID of the Outlet to connect to this host file |
| priceSet | [ID](/documentation/Types/UUID#UUID) | The ID of the Price Set to connect to this host file (if null, it will use the default price set) |
| metadata | [JSON!](/documentation/Types/JSON#JSON) | Any metadata related to the host type. Each host may expect this to be formatted in a certain way |
| settings | [JSON!](/documentation/Types/JSON#JSON) | The settings to provide to the host connection |
| credentials | [JSON!](/documentation/Types/JSON#JSON) | The credentials to use for the host connection. Each host will have this specified in a certain way |

**Example Mutation**

```graphql
mutation CreateHostConnection($type: HostConnectionTypeEnum!, $outlet: ID!, $metadata: JSON!, $settings: JSON!, $credentials: JSON!) {
    createHostConnection(type: $type, outlet: $outlet, metadata: $metadata, settings: $settings, credentials: $credentials) {
        id,
        type,
        metadata,
        settings,
        credentials
    }
}

# Example variables
{
    "type": "METCASH",
    "outlet": "<OUTLET>",
    "metadata": "<METADATA>",
    "settings": "<SETTINGS>",
    "credentials": "<CREDENTIALS>"
}
```

**Mutation**
## createItemFromHost — Returns [HostAppliableInterface](/documentation/Interfaces/Host-Appliable-Interface#HostAppliableInterface)

**Scopes required:** manage_host_changes

| Arguments | Type | Description |
| --- | --- | --- |
| id | *String!* | The ID of the item to create from the connection (this is the ID from the connection) |
| type | [HostAppliableTypeEnum!](/documentation/Enums/Host#HostAppliableTypeEnum) | The type of item that should be created |
| connection | [ID!](/documentation/Types/UUID#UUID) | The ID that the item should be created from |
| changeId | [ID](/documentation/Types/UUID#UUID) | The ID of the host change that this item is being created from |

**Example Mutation**

```graphql
mutation CreateItemFromHost($id: String!, $type: HostAppliableTypeEnum!, $connection: ID!) {
    createItemFromHost(id: $id, type: $type, connection: $connection) {
        id,
        name
    }
}

# Example variables
{
    "id": "<ID>",
    "type": "PRODUCT",
    "connection": "<CONNECTION>"
}
```

**Mutation**
## deleteHostConnection — Returns [HostConnection](/documentation/Objects/Host#HostConnection)

**Scopes required:** modify_host_connections

| Arguments | Type | Description |
| --- | --- | --- |
| id | [ID!](/documentation/Types/UUID#UUID) | The ID of the host connection you wish to update |

**Example Mutation**

```graphql
mutation DeleteHostConnection($id: ID!) {
    deleteHostConnection(id: $id) {
        id,
        type,
        metadata,
        settings,
        credentials
    }
}

# Example variables
{
    "id": "<ID>"
}
```

**Mutation**
## deleteHostIdentifier — Returns *boolean*

**Scopes required:** manage_host_changes

| Arguments | Type | Description |
| --- | --- | --- |
| connection | [ID!](/documentation/Types/UUID#UUID) | The ID of the host connection to delete the identifier from |
| identifier | *String!* | The ID of the identifier to remove |
| product | [ID!](/documentation/Types/UUID#UUID) | The ID of the product to delete the identifier from |

**Example Mutation**

```graphql
mutation DeleteHostIdentifier($connection: ID!, $identifier: String!, $product: ID!) {
    deleteHostIdentifier(connection: $connection, identifier: $identifier, product: $product)
}

# Example variables
{
    "connection": "<CONNECTION>",
    "identifier": "<IDENTIFIER>",
    "product": "<PRODUCT>"
}
```

**Mutation**
## ignoreHostChange — Returns [HostChange](/documentation/Objects/Host#HostChange)

**Scopes required:** manage_host_changes

| Arguments | Type | Description |
| --- | --- | --- |
| id | [ID!](/documentation/Types/UUID#UUID) | The ID of the host change to apply |
| autoProcessQueue | *Boolean* | Whether to automatically process the queue after applying the change, defaults to true |

**Example Mutation**

```graphql
mutation IgnoreHostChange($id: ID!) {
    ignoreHostChange(id: $id) {
        id,
        clientId,
        applyTo,
        rawMatch,
        change
    }
}

# Example variables
{
    "id": "<ID>"
}
```

**Mutation**
## mapHostIdentifier — Returns [HostAppliableInterface](/documentation/Interfaces/Host-Appliable-Interface#HostAppliableInterface)

**Scopes required:** manage_host_changes

| Arguments | Type | Description |
| --- | --- | --- |
| type | [HostAppliableTypeEnum!](/documentation/Enums/Host#HostAppliableTypeEnum) | The type of item to map |
| id | [ID!](/documentation/Types/UUID#UUID) | The ID of the item in Shopfront that is being mapped |
| connection | [ID!](/documentation/Types/UUID#UUID) | The ID of the host connection that will contain the mapping |
| hostIdentifier | *String!* | The identifier from the host connection to map |

**Example Mutation**

```graphql
mutation MapHostIdentifier($type: HostAppliableTypeEnum!, $id: ID!, $connection: ID!, $hostIdentifier: String!) {
    mapHostIdentifier(type: $type, id: $id, connection: $connection, hostIdentifier: $hostIdentifier) {
        id,
        name
    }
}

# Example variables
{
    "type": "PRODUCT",
    "id": "<ID>",
    "connection": "<CONNECTION>",
    "hostIdentifier": "<HOST_IDENTIFIER>"
}
```

**Mutation**
## separateDuplicateHostIdentifiers — Returns [[HostMappingProduct]](/documentation/Objects/Host#HostMappingProduct)

**Scopes required:** manage_host_changes

| Arguments | Type | Description |
| --- | --- | --- |
| product | [ID!](/documentation/Types/UUID#UUID) | The ID of the product with the duplicate mapping to separate |
| connection | [ID!](/documentation/Types/UUID#UUID) | The ID of the connection of the duplicate mappings to separate |
| inventory | [[SeparateHostItem!]](/documentation/Inputs/Host#SeparateHostItem) | The inventory levels of the separated products |

**Example Mutation**

```graphql
mutation SeparateDuplicateHostIdentifiers($product: ID!, $connection: ID!) {
    separateDuplicateHostIdentifiers(product: $product, connection: $connection) {
        __typename
    }
}

# Example variables
{
    "product": "<PRODUCT>",
    "connection": "<CONNECTION>"
}
```

**Mutation**
## updateHostConnection — Returns [HostConnection](/documentation/Objects/Host#HostConnection)

**Scopes required:** modify_host_connections

| Arguments | Type | Description |
| --- | --- | --- |
| id | [ID!](/documentation/Types/UUID#UUID) | The ID of the host connection you wish to update |
| metadata | [JSON!](/documentation/Types/JSON#JSON) | Any metadata related to the host type. Each host may expect this to be formatted in a certain way |
| settings | [JSON!](/documentation/Types/JSON#JSON) | The settings to provide to the host connection |
| credentials | [JSON!](/documentation/Types/JSON#JSON) | The credentials to use for the host connection. Each host will have this specified in a certain way |
| autoProcessQueue | *Boolean* | Whether to automatically process the queue after updating the settings |

**Example Mutation**

```graphql
mutation UpdateHostConnection($id: ID!, $metadata: JSON!, $settings: JSON!, $credentials: JSON!) {
    updateHostConnection(id: $id, metadata: $metadata, settings: $settings, credentials: $credentials) {
        id,
        type,
        metadata,
        settings,
        credentials
    }
}

# Example variables
{
    "id": "<ID>",
    "metadata": "<METADATA>",
    "settings": "<SETTINGS>",
    "credentials": "<CREDENTIALS>"
}
```