> For the complete documentation index, see [llms.txt](https://docs.pyck.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pyck.cloud/graphql-api/mutations/deleteinventoryrepositorymovement.md).

# Delete Inventory Repository Movement

Delete Inventory Repository Movement Mutation

Deletes an existing RepositoryMovement object from the system, removing a planned or pending repository-level operation such as consolidations, reorganizations, or bulk transfers.

## Arguments

| Name | Type  | Description                                                |
| ---- | ----- | ---------------------------------------------------------- |
| `id` | `ID!` | The unique identifier of the repository movement to delete |

## Return Type

`InventoryRepositoryMovementDeletePayload!` - Contains information about the deleted movement and related workflows.

## Return Fields

`InventoryRepositoryMovementDeletePayload`:

| Field       | Type                 | Description                                            |
| ----------- | -------------------- | ------------------------------------------------------ |
| `deletedID` | `ID`                 | The ID of the deleted repository movement              |
| `workflows` | `[TemporalWorkflow]` | Workflow instances that were triggered by the deletion |

## Usage Example

```graphql
mutation {
  deleteInventoryRepositoryMovement(id: "repo_movement_456") {
    deletedID
    workflows {
      id
      type
      status
      runID
      startedAt
      completedAt
      result
      failure
    }
  }
}
```

## JavaScript Example

```javascript
const DELETE_INVENTORY_REPOSITORY_MOVEMENT = gql`
  mutation DeleteInventoryRepositoryMovement($id: ID!) {
    deleteInventoryRepositoryMovement(id: $id) {
      deletedID
      workflows {
        id
        type
        status
        runID
        startedAt
        completedAt
        result
        failure
      }
    }
  }
`;

const { data } = await client.mutate({
  mutation: DELETE_INVENTORY_REPOSITORY_MOVEMENT,
  variables: {
    id: "repo_movement_456"
  }
});

console.log(`Deleted repository movement with ID: ${data.deleteInventoryRepositoryMovement.deletedID}`);

// Check for any triggered workflows
if (data.deleteInventoryRepositoryMovement.workflows.length > 0) {
  console.log('Triggered workflows:', data.deleteInventoryRepositoryMovement.workflows);
}
```

## Important Notes

* **Movement State**: Only non-executed repository movements can be deleted. Executed movements become part of the audit trail and cannot be removed
* **Scale Impact**: Repository movements typically affect large quantities of inventory, so deletion should be carefully considered
* **Workflow Triggers**: The deletion may trigger cleanup workflows, notification workflows, or resource deallocation workflows
* **Authorization**: Ensure you have proper permissions before deleting repository movements - typically requires supervisor-level access
* **Data Integrity**: The system will prevent deletion if the movement is part of an active collection or order
* **Resource Impact**: Deleting a repository movement may free up reserved resources like equipment and staff
* **Audit Trail**: Deletion events are logged for compliance and audit purposes
* **Recovery**: Once deleted, the repository movement cannot be recovered through the API

## Related Operations

After deleting a repository movement, you may need to:

* Release reserved equipment and staff resources
* Update related item movements that were part of the repository operation
* Notify affected stakeholders about the canceled operation
* Create replacement movements if the repository operation is still needed
* Update scheduling systems to remove blocked time slots

## Common Deletion Scenarios

1. **Cancel Consolidation**: Remove a planned repository consolidation that is no longer needed
2. **Correct Planning Errors**: Delete movements created with incorrect parameters or scope
3. **Resource Conflicts**: Remove movements when required resources are unavailable
4. **Strategic Changes**: Delete movements due to changes in warehouse strategy or priorities
5. **Regulatory Compliance**: Remove movements that would violate updated regulations
6. **Safety Concerns**: Delete movements that pose safety risks that cannot be mitigated

## Safety Considerations

Repository movements often involve:

* Large-scale equipment operation
* Multiple staff members
* Significant inventory value
* Complex logistics coordination

Ensure proper authorization and communication before deleting these movements to avoid operational disruptions.

## Error Handling

Common scenarios that may prevent deletion:

* **Executed Movement**: Cannot delete a repository movement that has already been executed. The system will return the error: "cannot delete an executed movement"
  * **Reason**: Executed movements have already transferred physical stock and are part of the permanent audit trail
  * **Solution**: Only pending (non-executed) movements can be deleted. For executed movements, consider creating a reverse movement instead
* **Insufficient Permissions**: User lacks permission to delete the movement (typically requires supervisor-level access)
* **Active References**: The movement is referenced in active workflows, collections, or dependent operations
* **Resource Constraints**: Equipment or staff resources are already committed and cannot be released
* **System Constraints**: Business rules prevent deletion due to operational or safety requirements

When attempting to delete an executed movement, handle the error appropriately:

```javascript
try {
  const { data } = await client.mutate({
    mutation: DELETE_INVENTORY_REPOSITORY_MOVEMENT,
    variables: { id: movementId }
  });
  console.log('Repository movement deleted successfully');
} catch (error) {
  if (error.message.includes('cannot delete an executed movement')) {
    console.error('This repository movement has already been executed and cannot be deleted');
    // Consider creating a reverse movement instead
  } else {
    console.error('Failed to delete repository movement:', error.message);
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pyck.cloud/graphql-api/mutations/deleteinventoryrepositorymovement.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
