> 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/deletesupplier.md).

# Delete Supplier

Delete Supplier Mutation

Deletes an existing supplier entity from the system.

## Arguments

| Name | Type  | Description                      |
| ---- | ----- | -------------------------------- |
| `id` | `ID!` | The ID of the supplier to delete |

## Return Type

`SupplierDeletePayload!` - Confirmation of the delete operation.

## Return Fields

`SupplierDeletePayload`:

| Field       | Type | Description                    |
| ----------- | ---- | ------------------------------ |
| `deletedID` | `ID` | The ID of the deleted supplier |

## Usage Example

```graphql
mutation {
  deleteSupplier(id: "supp_123456789") {
    deletedID
  }
}
```

```graphql
mutation {
  # Delete multiple suppliers (requires multiple calls)
  deleteSupplier1: deleteSupplier(id: "supp_111111111") {
    deletedID
  }
  deleteSupplier2: deleteSupplier(id: "supp_222222222") {
    deletedID
  }
  deleteSupplier3: deleteSupplier(id: "supp_333333333") {
    deletedID
  }
}
```

## JavaScript Example

```javascript
const DELETE_SUPPLIER = gql`
  mutation DeleteSupplier($id: ID!) {
    deleteSupplier(id: $id) {
      deletedID
    }
  }
`;

// Using the mutation
const [deleteSupplier] = useMutation(DELETE_SUPPLIER);

const handleDeleteSupplier = async (supplierId) => {
  try {
    const { data } = await deleteSupplier({
      variables: { id: supplierId }
    });
    
    console.log('Supplier deleted:', data.deleteSupplier.deletedID);
    // Update UI to remove the deleted supplier
  } catch (error) {
    console.error('Error deleting supplier:', error);
  }
};
```

## Important Considerations

### Soft vs Hard Delete

The pyck system implements soft deletes by default, meaning:

* The supplier record is marked as deleted (`deletedAt` timestamp is set)
* The supplier data remains in the database for audit purposes
* The supplier will not appear in normal queries
* Related data (purchase orders, receiving records) remains intact

### Data Integrity

Before deleting a supplier, consider:

* **Active Purchase Orders**: Check if the supplier has pending or active orders
* **Outstanding Invoices**: Verify all supplier invoices are processed
* **Inventory Dependencies**: Consider items that depend on this supplier
* **Contract Obligations**: Ensure deletion doesn't violate supplier agreements
* **Related Records**: Consider impact on receiving history and payments

### Supply Chain Impact

Supplier deletion affects:

* **Procurement Planning**: Future sourcing strategies
* **Inventory Management**: Replenishment planning for supplier-specific items
* **Cost Analysis**: Historical cost tracking and analysis
* **Quality Records**: Supplier performance and quality history

## Permissions

Supplier deletion typically requires:

* Administrative or procurement management privileges
* Proper authorization for the tenant/organization
* Compliance with procurement policies and audit requirements

## Error Scenarios

The mutation may fail in these cases:

* **Not Found**: Supplier ID doesn't exist
* **Permission Denied**: Insufficient privileges to delete suppliers
* **Constraint Violations**: Supplier has dependent records that prevent deletion
* **Business Rules**: Custom business logic prevents deletion (e.g., active contracts)
* **Financial Obligations**: Outstanding payments or invoices prevent deletion

## Best Practices

1. **Pre-Delete Validation**: Check for dependencies before deletion
2. **Stakeholder Notification**: Inform procurement and operations teams
3. **Data Export**: Back up supplier information before deletion
4. **Alternative Sourcing**: Identify replacement suppliers if needed
5. **Audit Documentation**: Document reasons for supplier removal
6. **Compliance Check**: Ensure deletion meets regulatory requirements

## Alternative Approaches

Instead of deletion, consider:

* **Deactivation**: Mark supplier as inactive rather than deleting
* **Status Change**: Move to "discontinued" or "blacklisted" status
* **Archiving**: Archive old suppliers while maintaining history
* **Replacement**: Replace with new supplier while maintaining relationships

## Related Operations

After supplier deletion, you may need to:

* Update inventory item sourcing information
* Modify purchase order templates
* Adjust procurement workflows
* Update supplier performance reports
* Revise vendor management dashboards

## Recovery

If a supplier is accidentally deleted:

* Contact system administrators immediately
* Soft deletes can typically be reversed by clearing the `deletedAt` timestamp
* Hard deletes may require restoration from backups
* Re-establish supplier relationships and data as needed


---

# 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/deletesupplier.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.
