Ayon Post Event & Enroll Event APIs

Hi there! I want to define custom events and trigger them via the Post Event API of Ayon and then also listen to them using the Enroll Event API.

Let’s say I use this json for Post Event

{
  "topic": "media.import",
  "sender": "service-processor-01",
  "hash": "string3",
  "project": "MyProject",
  "dependsOn": "69dd9b85a522fcedc14203ea95f54f52",
  "description": "Importing file 3 of 10",
  "summary": {},
  "payload": {},
  "finished": true,
  "store": true,
  "reuse": false
}

And then to enroll I use

{
  "sourceTopic": ["media.import"],
  "targetTopic": "listen.to.media.import",
  "sender": "service-processor-01",
  "senderType": "worker",
  "description": "listen to custom event",
  "sequential": true,
  "ignoreOlderThan": 0,
  "slothMode": false
}

If I call the Enroll Event using Postman for example I always get this result

{
    "code": 403,
    "detail": "Only services can enroll for jobs"
}

Why is that? Do I need to create a new custom service? how?Is it not enough that I specify a sender when I use the Post Event

This actually refers to service users, not a service process. It seems you are using a normal user for the request.

Instead, create a service user and use its API key to run the request. Both sender and sender type are optional, but it is necessary to use at least “sender” in the case there’s multiple instances of the same service running - sender could be service name for example while sender type could be service type/image.

then you can use the following headers:

x-api-key: YOUR_SERVICE_USER_API_KEY
x-sender: media_processor_01
x-sender-type: media_processor
1 Like