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

# CustomEventPayloadInput

CustomEventPayloadInput Input Type

Audience: Programmer

A structured input type for custom event payloads in the pyck event system. This input type provides a standardized way to send custom events with a required entity identifier and optional additional data.

## Fields

| Field  | Type  | Required | Description                                        |
| ------ | ----- | -------- | -------------------------------------------------- |
| `id`   | `ID!` | Yes      | The identifier of the entity this event relates to |
| `data` | `Map` | No       | Optional additional data and context information   |

## Field Details

### id (required)

The `id` field is the primary identifier for the entity that the custom event relates to. This could be:

* An inventory item ID
* A customer ID
* A picking order ID
* A device ID
* Any other entity identifier in the system

This field is required to ensure events are properly associated with entities and can trigger appropriate workflows.

### data (optional)

The `data` field accepts a flexible Map (JSON object) that can contain any additional context information for the event. This allows for:

* Custom attributes specific to your event type
* Nested objects for complex data structures
* Arrays for lists of related items
* Any JSON-compatible data types

## Usage

This input type is used exclusively with the [`sendCustomEvent`](/graphql-api/mutations/sendcustomevent.md) mutation.

## Example

### Basic Usage

```graphql
mutation {
  sendCustomEvent(
    input: {
      type: "inventory"
      operation: "stock_check"
      payload: {
        id: "item_123456"
        data: {
          "warehouseId": "wh_main",
          "currentQuantity": 50,
          "checkType": "routine"
        }
      }
    }
  ) {
    success
    workflows {
      type
      id
      runID
    }
  }
}
```

### Minimal Payload (ID only)

When you only need to identify the entity without additional data:

```graphql
mutation {
  sendCustomEvent(
    input: {
      type: "device"
      operation: "heartbeat"
      payload: {
        id: "device_scanner_001"
      }
    }
  ) {
    success
    workflows {
      type
      id
      runID
    }
  }
}
```

### Complex Data Structure

```graphql
mutation {
  sendCustomEvent(
    input: {
      type: "order"
      operation: "shipment_update"
      payload: {
        id: "order_789"
        data: {
          "shipmentId": "ship_456",
          "carrier": "FedEx",
          "trackingNumber": "1234567890",
          "status": "in_transit",
          "estimatedDelivery": "2025-01-20T14:00:00Z",
          "packages": [
            {
              "packageId": "pkg_001",
              "weight": 2.5,
              "dimensions": {
                "length": 30,
                "width": 20,
                "height": 15
              }
            }
          ],
          "notifyCustomer": true
        }
      }
    }
  ) {
    success
    workflows {
      type
      id
      runID
    }
  }
}
```

## JavaScript Example

```javascript
const SEND_CUSTOM_EVENT = gql`
  mutation SendCustomEvent($input: SendCustomEventInput!) {
    sendCustomEvent(input: $input) {
      success
      workflows {
        type
        id
        runID
      }
    }
  }
`;

// Build the payload
const payload = {
  id: entity.id,  // Required: entity identifier
  data: {         // Optional: additional context
    action: "update",
    previousValue: entity.oldValue,
    newValue: entity.newValue,
    reason: "user_request",
    metadata: {
      source: "web_app",
      timestamp: new Date().toISOString()
    }
  }
};

// Send the event
const { data } = await client.mutate({
  mutation: SEND_CUSTOM_EVENT,
  variables: {
    input: {
      type: "entity",
      operation: "modified",
      payload: payload
    }
  }
});

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

## Migration from Map Payload

If you were previously using the `Map` type for payloads, you need to restructure your data:

**Before (deprecated)**:

```graphql
payload: {
  "entityId": "123",
  "name": "Example",
  "value": 100
}
```

**After (current)**:

```graphql
payload: {
  id: "123"
  data: {
    "name": "Example",
    "value": 100
  }
}
```

## Best Practices

1. **Use meaningful IDs**: The `id` field should reference a valid entity in your system
2. **Keep data structured**: Organize related fields into nested objects for clarity
3. **Avoid sensitive data**: Do not include passwords, API keys, or other secrets in the data field
4. **Document your schemas**: Maintain documentation for the data structure expected by each event type
5. **Validate client-side**: Validate the payload structure before sending to catch errors early

## Related Documentation

* [sendCustomEvent Mutation](/graphql-api/mutations/sendcustomevent.md)
* [Map Scalar](/graphql-api/scalars/map.md)
* [TemporalWorkflow Type](/graphql-api/types/temporalworkflow.md)

## Service

This input type is defined in the **Management** service.


---

# 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/inputs/customeventpayloadinput.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.
