Create Role

Create Role
Create a role

This endpoint creates a new role for a user in an organization or space.

To create an organization role you must be an admin or organization manager in the organization associated with the role.

To create a space role you must be an admin, an organization manager in the parent organization of the space associated with the role, or a space manager in the space associated with the role.

For a user to be assigned a space role, the user must already have an organization role in the parent organization.

If the associated user is valid but does not exist in Cloud Controller’s database, a user resource will be created automatically.

If CAPI property cc.allow_user_creation_by_org_manager is enabled, the organization role is being created by username + origin and the user does not exist in UAA yet, the user will be created. The origin must be different from uaa in this case.

Request
URI
POST
https://api.example.local/v3/roles
COPY
Request Body

Role to create

RoleCreate of type(s) application/json
Optional
{
    "type": "string",
    "relationships": {
        "user": {
            "data": {
                "guid": "string"
            }
        },
        "organization": {
            "data": {
                "guid": "string"
            },
            "links": {
                "self": {
                    "href": "string",
                    "method": "string"
                },
                "related": {
                    "href": "string",
                    "method": "string"
                }
            }
        },
        "space": {
            "data": {
                "guid": "string"
            },
            "links": {
                "self": {
                    "href": "string",
                    "method": "string"
                },
                "related": {
                    "href": "string",
                    "method": "string"
                }
            }
        }
    }
}
Authentication
This operation uses the following authentication methods.
Responses
201

Role created

Returns Role of type(s) application/json
This response body class contains all of the following: BaseSchema
{
    "guid": "string",
    "created_at": "string",
    "updated_at": "string",
    "type": "string",
    "relationships": {
        "organization": {
            "data": {
                "guid": "string"
            },
            "links": {
                "self": {
                    "href": "string",
                    "method": "string"
                },
                "related": {
                    "href": "string",
                    "method": "string"
                }
            }
        },
        "space": {
            "data": {
                "guid": "string"
            },
            "links": {
                "self": {
                    "href": "string",
                    "method": "string"
                },
                "related": {
                    "href": "string",
                    "method": "string"
                }
            }
        },
        "user": {
            "data": {
                "guid": "string"
            }
        }
    },
    "links": {
        "self": {
            "href": "string",
            "method": "string"
        },
        "user": {
            "href": "string",
            "method": "string"
        },
        "organization": {
            "href": "string",
            "method": "string"
        },
        "space": {
            "href": "string",
            "method": "string"
        }
    },
    "included": {
        "spaces": [
            {
                "guid": "string",
                "created_at": "string",
                "updated_at": "string",
                "name": "string",
                "relationships": {
                    "organization": {
                        "data": {
                            "guid": "string"
                        },
                        "links": {
                            "self": {
                                "href": "string",
                                "method": "string"
                            },
                            "related": {
                                "href": "string",
                                "method": "string"
                            }
                        }
                    },
                    "quota": {
                        "data": {
                            "guid": "string"
                        },
                        "links": {
                            "self": {
                                "href": "string",
                                "method": "string"
                            },
                            "related": {
                                "href": "string",
                                "method": "string"
                            }
                        }
                    }
                },
                "links": {
                    "self": {
                        "href": "string",
                        "method": "string"
                    },
                    "organization": {
                        "href": "string",
                        "method": "string"
                    },
                    "features": {
                        "href": "string",
                        "method": "string"
                    },
                    "apply_manifest": {
                        "href": "string",
                        "method": "string"
                    }
                },
                "metadata": {
                    "labels": {
                        "labels": "string"
                    },
                    "annotations": {
                        "annotations": "string"
                    }
                },
                "included": "IncludedResources Object"
            }
        ],
        "organizations": [
            {
                "guid": "string",
                "created_at": "string",
                "updated_at": "string",
                "name": "string",
                "suspended": false,
                "relationships": {
                    "quota": {
                        "data": {
                            "guid": "string"
                        },
                        "links": {
                            "self": {
                                "href": "string",
                                "method": "string"
                            },
                            "related": {
                                "href": "string",
                                "method": "string"
                            }
                        }
                    }
                },
                "metadata": {
                    "labels": {
                        "labels": "string"
                    },
                    "annotations": {
                        "annotations": "string"
                    }
                },
                "links": {
                    "self": {
                        "href": "string",
                        "method": "string"
                    },
                    "domains": {
                        "href": "string",
                        "method": "string"
                    },
                    "quota": {
                        "href": "string",
                        "method": "string"
                    },
                    "default_domain": {
                        "href": "string",
                        "method": "string"
                    }
                }
            }
        ],
        "domains": [
            {
                "guid": "string",
                "created_at": "string",
                "updated_at": "string",
                "name": "string",
                "internal": false,
                "router_group": {
                    "guid": "string"
                },
                "supported_protocols": [
                    "string"
                ],
                "enforce_route_policies": false,
                "route_policies_scope": "string",
                "relationships": {
                    "organization": {
                        "data": {
                            "guid": "string"
                        },
                        "links": {
                            "self": {
                                "href": "string",
                                "method": "string"
                            },
                            "related": {
                                "href": "string",
                                "method": "string"
                            }
                        }
                    },
                    "shared_organizations": {
                        "data": [
                            {
                                "guid": "string"
                            }
                        ],
                        "links": {
                            "self": {
                                "href": "string",
                                "method": "string"
                            },
                            "related": {
                                "href": "string",
                                "method": "string"
                            }
                        }
                    }
                },
                "metadata": {
                    "labels": {
                        "labels": "string"
                    },
                    "annotations": {
                        "annotations": "string"
                    }
                },
                "links": {
                    "self": {
                        "href": "string",
                        "method": "string"
                    },
                    "organization": {
                        "href": "string",
                        "method": "string"
                    },
                    "route_reservations": {
                        "href": "string",
                        "method": "string"
                    },
                    "shared_organizations": {
                        "href": "string",
                        "method": "string"
                    },
                    "router_group": {
                        "href": "string",
                        "method": "string"
                    }
                }
            }
        ],
        "service_offerings": [
            {
                "guid": "string",
                "created_at": "string",
                "updated_at": "string",
                "service_broker_guid": "string",
                "service_broker_name": "string",
                "metadata": {
                    "labels": {
                        "labels": "string"
                    },
                    "annotations": {
                        "annotations": "string"
                    }
                },
                "links": {
                    "self": {
                        "href": "string",
                        "method": "string"
                    },
                    "service_plans": {
                        "href": "string",
                        "method": "string"
                    },
                    "service_broker": {
                        "href": "string",
                        "method": "string"
                    }
                }
            }
        ],
        "service_instances": [
            {
                "guid": "string",
                "created_at": "string",
                "updated_at": "string",
                "type": "string",
                "name": "string",
                "tags": [
                    "string"
                ],
                "syslog_drain_url": "string",
                "route_service_url": "string",
                "dashboard_url": "string",
                "maintenance_info": {
                    "version": "string",
                    "description": "string"
                },
                "upgrade_available": false,
                "last_operation": {
                    "type": "string",
                    "state": "string",
                    "description": "string",
                    "created_at": "string",
                    "updated_at": "string"
                },
                "relationships": {
                    "space": {
                        "data": {
                            "guid": "string"
                        },
                        "links": {
                            "self": {
                                "href": "string",
                                "method": "string"
                            },
                            "related": {
                                "href": "string",
                                "method": "string"
                            }
                        }
                    },
                    "service_plan": {
                        "data": {
                            "guid": "string"
                        },
                        "links": {
                            "self": {
                                "href": "string",
                                "method": "string"
                            },
                            "related": {
                                "href": "string",
                                "method": "string"
                            }
                        }
                    }
                },
                "links": {
                    "self": {
                        "href": "string",
                        "method": "string"
                    },
                    "space": {
                        "href": "string",
                        "method": "string"
                    },
                    "service_plan": {
                        "href": "string",
                        "method": "string"
                    },
                    "parameters": {
                        "href": "string",
                        "method": "string"
                    },
                    "service_credential_bindings": {
                        "href": "string",
                        "method": "string"
                    },
                    "service_route_bindings": {
                        "href": "string",
                        "method": "string"
                    },
                    "shared_spaces": {
                        "href": "string",
                        "method": "string"
                    }
                },
                "metadata": {
                    "labels": {
                        "labels": "string"
                    },
                    "annotations": {
                        "annotations": "string"
                    }
                }
            }
        ],
        "apps": [
            {
                "guid": "string",
                "created_at": "string",
                "updated_at": "string",
                "name": "string",
                "state": "string",
                "lifecycle": {
                    "type": "string",
                    "data": {
                        "buildpacks": [
                            "string"
                        ],
                        "stack": "string",
                        "credentials": {
                            "credentials": {
                                "username": "string",
                                "password": "string",
                                "token": "string"
                            }
                        }
                    }
                },
                "relationships": {},
                "metadata": {
                    "labels": {
                        "labels": "string"
                    },
                    "annotations": {
                        "annotations": "string"
                    }
                },
                "links": {
                    "self": {
                        "href": "string",
                        "method": "string"
                    },
                    "space": {
                        "href": "string",
                        "method": "string"
                    },
                    "processes": {
                        "href": "string",
                        "method": "string"
                    },
                    "packages": {
                        "href": "string",
                        "method": "string"
                    },
                    "environment_variables": {
                        "href": "string",
                        "method": "string"
                    },
                    "current_droplet": {
                        "href": "string",
                        "method": "string"
                    },
                    "droplets": {
                        "href": "string",
                        "method": "string"
                    },
                    "tasks": {
                        "href": "string",
                        "method": "string"
                    },
                    "start": {
                        "href": "string",
                        "method": "string"
                    },
                    "stop": {
                        "href": "string",
                        "method": "string"
                    },
                    "revisions": {
                        "href": "string",
                        "method": "string"
                    },
                    "deployed_revisions": {
                        "href": "string",
                        "method": "string"
                    },
                    "features": {
                        "href": "string",
                        "method": "string"
                    }
                },
                "included": "IncludedResources Object"
            }
        ],
        "routes": [
            {
                "guid": "string",
                "created_at": "string",
                "updated_at": "string",
                "protocol": "string",
                "host": "string",
                "path": "string",
                "port": 0,
                "url": "string",
                "relationships": {},
                "metadata": {
                    "labels": {
                        "labels": "string"
                    },
                    "annotations": {
                        "annotations": "string"
                    }
                },
                "links": {
                    "self": {
                        "href": "string",
                        "method": "string"
                    },
                    "space": {
                        "href": "string",
                        "method": "string"
                    },
                    "domain": {
                        "href": "string",
                        "method": "string"
                    },
                    "destinations": {
                        "href": "string",
                        "method": "string"
                    }
                },
                "included": "IncludedResources Object"
            }
        ],
        "users": [
            {
                "guid": "string",
                "created_at": "string",
                "updated_at": "string",
                "username": "string",
                "presentation_name": "string",
                "origin": "string",
                "metadata": {
                    "labels": {
                        "labels": "string"
                    },
                    "annotations": {
                        "annotations": "string"
                    }
                },
                "links": {
                    "self": {
                        "href": "string",
                        "method": "string"
                    }
                }
            }
        ]
    }
}
string
type
Optional

Role type. Possible values are:

  • organization_user: A user in the organization
  • organization_auditor: An auditor in the organization
  • organization_manager: A manager in the organization
  • organization_billing_manager: A billing manager in the organization
  • space_auditor: An auditor in the space
  • space_developer: A developer in the space
  • space_manager: A manager in the space
  • space_supporter: A supporter in the space (not authorized to use the V2 API)
Enumeration: organization_user, organization_auditor, organization_manager, organization_billing_manager, space_auditor, space_developer, space_manager, space_supporter
relationships
Optional

relationships

object
links
Optional

links

object
included
Optional

Additional related resources included in the response when using the include parameter


400

Bad Request

Returns BadRequest of type(s) application/json
{
    "errors": [
        {
            "code": 0,
            "detail": "string",
            "title": "string"
        }
    ]
}
array of object
errors
Optional

errors


401

Unauthorized

Returns Unauthorized of type(s) application/json
{
    "errors": [
        {
            "code": 0,
            "detail": "string",
            "title": "string"
        }
    ]
}
array of object
errors
Optional

errors


403

Forbidden

Returns Forbidden of type(s) application/json
{
    "errors": [
        {
            "code": 0,
            "detail": "string",
            "title": "string"
        }
    ]
}
array of object
errors
Optional

errors


409

Conflict

Returns Conflict of type(s) application/json
{
    "errors": [
        {
            "code": 0,
            "detail": "string",
            "title": "string"
        }
    ]
}
array of object
errors
Optional

errors


422

Unprocessable Entity

Returns UnprocessableEntity of type(s) application/json
{
    "errors": [
        {
            "code": 0,
            "detail": "string",
            "title": "string"
        }
    ]
}
array of object
errors
Optional

errors


429

Too Many Requests

Returns TooManyRequests of type(s) application/json
{
    "errors": [
        {
            "code": 0,
            "title": "string",
            "detail": "string"
        }
    ]
}
array of object
errors
Optional

errors


500

Internal Server Error

Returns 500 of type(s) application/json
{
    "errors": [
        {
            "code": 0,
            "detail": "string",
            "title": "string"
        }
    ]
}
array of object
errors
Optional

errors


503

Service Unavailable

Returns ServiceUnavailable of type(s) application/json
{
    "errors": [
        {
            "code": 0,
            "detail": "string",
            "title": "string"
        }
    ]
}
array of object
errors
Optional

errors


Code Samples
COPY
                    curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '{}' https://{api_host}/v3/roles