We have updated our Terms of Service, Code of Conduct, and Addendum.

Using the API to create new routes

Brandon McCombs
Brandon McCombs Posts: 150 mod

How can I use the Stream REST API to create new routes? The API doc reference doesn’t show a POST but I do see a PATCH. Is PATCH the operation I should use? Can someone provide an example payload by chance?

Best Answer

  • Rob Franz
    Rob Franz Posts: 33 mod
    Answer ✓

    You can create routes in Stream by utilizing this endpoint using the PATCH method, e.g.
    http://localhost:19000/api/v1/m/default/routes/default

    A sample payload could be:
    {'id': 'random456', 'routes': [ {'id': 'random123', 'name': 'Route 1234', 'final': True, 'disabled': False, 'pipeline': 'main', 'description': 'hello, i was created by the API', 'clones': [], 'enableOutputExpression': False, 'filter': 'true', 'output': 'default'} ]}

    Note that this may overwrite the existing routes, so please take the necessary steps to export them. This can be done manually in the UI, or via the API by using the GET method on the /routes endpoint. You could also build functionality in a script to:

    1. call the GET method on the /routes endpoint
    2. take the JSON returned from the call and add the new route JSON to it (e.g. a new JSON object in the ‘routes list in the example above)
    3. call the PATCH method and send the new JSON

Answers

  • Rob Franz
    Rob Franz Posts: 33 mod
    Answer ✓

    You can create routes in Stream by utilizing this endpoint using the PATCH method, e.g.
    http://localhost:19000/api/v1/m/default/routes/default

    A sample payload could be:
    {'id': 'random456', 'routes': [ {'id': 'random123', 'name': 'Route 1234', 'final': True, 'disabled': False, 'pipeline': 'main', 'description': 'hello, i was created by the API', 'clones': [], 'enableOutputExpression': False, 'filter': 'true', 'output': 'default'} ]}

    Note that this may overwrite the existing routes, so please take the necessary steps to export them. This can be done manually in the UI, or via the API by using the GET method on the /routes endpoint. You could also build functionality in a script to:

    1. call the GET method on the /routes endpoint
    2. take the JSON returned from the call and add the new route JSON to it (e.g. a new JSON object in the ‘routes list in the example above)
    3. call the PATCH method and send the new JSON