rubenf
rubenf12mo ago

Ask Inkeep

@Ask Inkeep how to return custom status codes
7 Replies
Ask Inkeep
Ask Inkeep12mo ago
Thanks for tagging me @rubenf. I'll look through relevant sources and get back to you in less than a minute. ----------------------------- While I generate an answer, here are some sources that might be helpful: * Custom Response Code * Go Quickstart * Webhooks * GET /workers/custom_tags -----------------------------
Ask Inkeep
Ask Inkeep12mo ago
Answer In Windmill, you can return custom status codes from your scripts for synchronous run jobs endpoints. When your script's response contains a key named windmill_status_code with a numerical value, that value will be used as the status code of the response (1) (2) . As an example, if you want to return a 201 status code, your script's response should include {"windmill_status_code": 201}. Please note this only applies to synchronous run jobs endpoints (2) .
Ask Inkeep
Ask Inkeep12mo ago
Feel free to tag me @Ask Inkeep for any follow-ups on this thread. Also appreciate any feedback, it helps me improve.
netpro25
netpro2512mo ago
@Ask Inkeep Would this work? return '{"windmill_status_code": 401}'
Ask Inkeep
Ask Inkeep12mo ago
Thanks for the follow-up, @netpro25. I'll get back to you soon. ----------------------------- While I generate an answer, here are some sources that might be helpful: * Custom Response Code * Go Quickstart * Webhooks * GET /w/{workspace}/inputs/list -----------------------------
Ask Inkeep
Ask Inkeep12mo ago
Answer Yes, your response would correctly return a 401 status code, as it follows the format stated in Windmill's documentation (1) . The key windmill_status_code with its value set to 401 would set the HTTP status code of the response. Remember that this only applies for synchronous run job endpoints.
Ask Inkeep
Ask Inkeep12mo ago
Feel free to tag me @Ask Inkeep for any follow-ups on this thread. Also appreciate any feedback, it helps me improve.