Openwork Roles API

Organization custom role management routes.

OpenAPI Specification

openwork-roles-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Den Admin Roles API
  description: 'OpenAPI spec for the Den control plane API.


    Authentication:

    - Use `Authorization: Bearer <session-token>` for user-authenticated routes that require a Den session.

    - Use `x-api-key: <den-api-key>` for API-key-authenticated routes that accept organization API keys.

    - Public routes like health and documentation do not require authentication.


    Swagger tip: use the security schemes in the Authorize dialog to set either `bearerAuth` or `denApiKey` before trying protected endpoints.'
  version: dev
servers:
- url: https://api.openworklabs.com
tags:
- name: Roles
  description: Organization custom role management routes.
paths:
  /v1/roles:
    post:
      operationId: postV1Roles
      tags:
      - Roles
      summary: Create organization role
      description: Creates a custom organization role with a named permission map.
      responses:
        '201':
          description: Organization role created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse'
        '400':
          description: The role creation request was invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestError'
        '401':
          description: The caller must be signed in to create organization roles.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '403':
          description: Only workspace owners can create custom roles.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenError'
        '404':
          description: The organization could not be found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                roleName:
                  type: string
                  minLength: 2
                  maxLength: 64
                permission:
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    type: array
                    items:
                      type: string
              required:
              - roleName
              - permission
  /v1/roles/{roleId}:
    patch:
      operationId: patchV1RolesByRoleId
      tags:
      - Roles
      summary: Update organization role
      description: Updates a custom organization role and propagates role name changes to members and pending invitations.
      responses:
        '200':
          description: Organization role updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse'
        '400':
          description: The role update request was invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestError'
        '401':
          description: The caller must be signed in to update organization roles.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '403':
          description: Only workspace owners can update custom roles.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenError'
        '404':
          description: The role or organization could not be found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
      parameters:
      - in: path
        name: roleId
        schema:
          format: typeid
          type: string
          minLength: 30
          maxLength: 30
          pattern: ^orl_.*
        required: true
        description: Den TypeID with 'orl_' prefix and a 26-character base32 suffix.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                roleName:
                  type: string
                  minLength: 2
                  maxLength: 64
                permission:
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    type: array
                    items:
                      type: string
    delete:
      operationId: deleteV1RolesByRoleId
      tags:
      - Roles
      summary: Delete organization role
      description: Deletes a custom organization role after confirming that no members or pending invitations still depend on it.
      responses:
        '204':
          description: Organization role deleted successfully.
        '400':
          description: The role deletion request was invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestError'
        '401':
          description: The caller must be signed in to delete organization roles.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '403':
          description: Only workspace owners can delete custom roles.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenError'
        '404':
          description: The role or organization could not be found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
      parameters:
      - in: path
        name: roleId
        schema:
          format: typeid
          type: string
          minLength: 30
          maxLength: 30
          pattern: ^orl_.*
        required: true
        description: Den TypeID with 'orl_' prefix and a 26-character base32 suffix.
components:
  schemas:
    InvalidRequestError:
      type: object
      properties:
        error:
          type: string
          const: invalid_request
        details:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
              path:
                type: array
                items:
                  anyOf:
                  - type: string
                  - type: number
            required:
            - message
            additionalProperties: {}
      required:
      - error
      - details
    NotFoundError:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
      required:
      - error
    ForbiddenError:
      type: object
      properties:
        error:
          type: string
          enum:
          - forbidden
          - reauth
        reason:
          type: string
        message:
          type: string
      required:
      - error
    SuccessResponse:
      type: object
      properties:
        success:
          type: boolean
          const: true
      required:
      - success
    UnauthorizedError:
      type: object
      properties:
        error:
          type: string
          const: unauthorized
      required:
      - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: session-token
      description: 'Session token passed as `Authorization: Bearer <session-token>` for user-authenticated Den routes.'
    denApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Organization API key passed as the `x-api-key` header for API-key-authenticated Den routes.