Organization creation endpoint returns 500

Feature: Organization creation endpoint from Management API.

Description: The POST /api/v2/organizations endpoint returns a 500 error in some scenarios. The root cause is clear and can be easily avoided from users’ perspective, but a 500 should not be returned anyway.

Use-case: We basically wanted to call the POST /api/v2/organizations endpoint, but only the name body parameter was needed. We tried to call it by setting most of the other parameters as empty, but a 500 error was returned.

The body was as follows:

{
  "name": "Some name",
  "branding": {},
  "metadata": {},
  "enabled_connections": []
}

We would have expected the API to behave in one of these two ways:

  • Return a 201, because having empty parameters could be handled as if they were not specified.

  • Return a 400, if we are not supposed to send empty parameters.

The solution as API users was easy, as not sending those empty parameters is enough to get the expected API response, but we wanted to raise it here because a 500 error is likely a bug due to unhandled errors.