Skip to content

ADD support for idempotent subscription creation #4684

@tzzed

Description

@tzzed

Is your feature request related to a problem / use case? Please describe.
When deploying subscriptions automatically (e.g. via CI/CD or infrastructure as code), it is easy to create duplicates of the same subscription unintentionally. Currently, Orion allows the creation of multiple subscriptions with the same parameters (e.g. same description, subject, notification). This results in multiple redundant notifications being sent, which can be problematic in production environment

Describe the solution you'd like
I would like a mechanism to prevent the creation of duplicate subscriptions. This could take several forms:

Return an HTTP 409 Conflict if an identical subscription already exists (based on a defined uniqueness criteria).

Support a rejectIfExists flag in the POST /v2/subscriptions request body.

Support a user-defined idempotencyKey or allow description to be a unique key.

Example request:

POST /v2/subscriptions
Content-Type: application/json

{
  "description": "Notify when temperature > 30",
  "subject": { ... },
  "notification": { ... },
  "rejectIfExists": true
}

If a subscription with the same description, subject, and notification already exists, the creation should fail gracefully.

Describe alternatives you've considered

  • Listing all subscriptions (GET /v2/subscriptions) and manually comparing them before creating a new one — but this introduces complexity and race conditions.

  • Deleting all subscriptions before recreating them — but this breaks idempotency and causes temporary unsubscription.

Describe why you need this feature

  • To improve and simplify infrastructure automation and avoid race conditions.
  • To ensure subscriptions are unique and avoid redundant notifications.
  • To help maintain clarity and reduce load on both Orion and subscribers.

Additional information
Add any other information, diagrams or screenshots about the feature request here.
This behavior is common in modern APIs that support idempotent creation. It would also be useful in orchestrated systems like Kubernetes or Terraform.
Do you have the intention to implement the solution

  • Yes, I have the knowledge to implement this new feature.
  • Yes, but I will need help.
  • No, I do not have the skills.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions