check this -
Interacting with Workflows Programmatically - check how workItem is used
You can use the Workflow API to work with payloads via a custom workflow step.
You can get information such as the JCR path of the payload, etc.
Furthermore - you can use other AEM APIs - like AssetManager API - to work with a given payload at the API level.
To see a good example - see this - where we modify a payload based on a property. This will give you a solid understanding...