openapi: 3.2.0 info: title: B2B-OldKAIExtract Prompts API description: 'Extract structured information from documents. ## Using the API ### Optional Parameters When using the ''Try it out'' feature in Swagger UI, optional parameters with empty values can be left as-is. The API handles empty strings and will treat them as if the parameter was omitted. You don''t need to remove empty optional fields from requests. **Tip:** In generated curl commands, you may see flags like `-F ''tag=''` or `-F ''tools=''`. These empty optional fields are safe to include or remove - the API treats them identically.' version: 0.1.0 servers: - url: https://gateway.api.kuehne-nagel.com/oldkaiextractapi/0.1.0 - url: http://gateway.api.kuehne-nagel.com:8280/oldkaiextractapi/0.1.0 security: - default: [] tags: - name: prompts description: Manage prompts for workspaces. paths: /v3/workspaces/{workspace_id}/prompts: get: tags: - prompts summary: List Prompts description: List all prompts available for a workspace identified by UUID. operationId: list_prompts_v3_workspaces__workspace_id__prompts_get parameters: - name: workspace_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Workspace Id - name: x-auth-request-email in: header required: false style: simple explode: false schema: anyOf: - type: string - type: 'null' title: X-Auth-Request-Email responses: '200': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/PromptListResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - default: [] x-auth-type: Application & Application User x-throttling-tier: Unlimited post: tags: - prompts summary: Create Prompt description: Create a new prompt in the workspace. operationId: create_prompt_v3_workspaces__workspace_id__prompts_post parameters: - name: workspace_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Workspace Id - name: x-auth-request-email in: header required: true style: simple explode: false schema: type: string title: X-Auth-Request-Email requestBody: content: application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/Body_create_prompt_v3_workspaces__workspace_id__prompts_post' required: true responses: '201': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/PromptDetailResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - default: [] x-auth-type: Application & Application User x-throttling-tier: Unlimited /v3/workspaces/{workspace_id}/prompts/{prompt_id}: get: tags: - prompts summary: Get Prompt description: Get detailed information about a specific prompt identified by UUID. operationId: get_prompt_v3_workspaces__workspace_id__prompts__prompt_id__get parameters: - name: prompt_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Prompt Id - name: workspace_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Workspace Id - name: all_versions in: query description: Include all prompt versions instead of filtered set required: false style: form explode: true schema: type: boolean default: false description: Include all prompt versions instead of filtered set title: All Versions - name: x-auth-request-email in: header required: true style: simple explode: false schema: type: string title: X-Auth-Request-Email responses: '200': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/PromptDetailResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - default: [] x-auth-type: Application & Application User x-throttling-tier: Unlimited put: tags: - prompts summary: Update Prompt description: Update an existing prompt. operationId: update_prompt_v3_workspaces__workspace_id__prompts__prompt_id__put parameters: - name: prompt_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Prompt Id - name: workspace_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Workspace Id - name: x-auth-request-email in: header required: true style: simple explode: false schema: type: string title: X-Auth-Request-Email requestBody: content: application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/Body_update_prompt_v3_workspaces__workspace_id__prompts__prompt_id__put' responses: '200': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/PromptDetailResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - default: [] x-auth-type: Application & Application User x-throttling-tier: Unlimited delete: tags: - prompts summary: Delete Prompt description: 'Delete a prompt. By default performs soft delete, set hard_delete=True for permanent deletion.' operationId: delete_prompt_v3_workspaces__workspace_id__prompts__prompt_id__delete parameters: - name: prompt_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Prompt Id - name: workspace_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Workspace Id - name: x-auth-request-email in: header required: true style: simple explode: false schema: type: string title: X-Auth-Request-Email requestBody: content: application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/Body_delete_prompt_v3_workspaces__workspace_id__prompts__prompt_id__delete' responses: '200': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/DeletePromptResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - default: [] x-auth-type: Application & Application User x-throttling-tier: Unlimited /v3/api-key-auth/workspaces/{workspace_id}/prompts: get: tags: - prompts summary: List Prompts Api Key description: List all prompts available for a workspace using API key authentication. operationId: list_prompts_api_key_v3_api_key_auth_workspaces__workspace_id__prompts_get parameters: - name: workspace_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Workspace Id - name: x-api-key in: header required: true style: simple explode: false schema: type: string title: X-Api-Key responses: '200': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/PromptListResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - default: [] x-auth-type: Application & Application User x-throttling-tier: Unlimited post: tags: - prompts summary: Create Prompt Api Key description: Create a new prompt in the workspace using API key authentication. operationId: create_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts_post parameters: - name: workspace_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Workspace Id - name: x-api-key in: header required: true style: simple explode: false schema: type: string title: X-Api-Key requestBody: content: application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/Body_create_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts_post' required: true responses: '201': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/PromptDetailResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - default: [] x-auth-type: Application & Application User x-throttling-tier: Unlimited /v3/api-key-auth/workspaces/{workspace_id}/prompts/{prompt_id}: get: tags: - prompts summary: Get Prompt Api Key description: Get detailed information about a specific prompt using API key authentication. operationId: get_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts__prompt_id__get parameters: - name: prompt_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Prompt Id - name: workspace_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Workspace Id - name: all_versions in: query description: Include all prompt versions instead of filtered set required: false style: form explode: true schema: type: boolean default: false description: Include all prompt versions instead of filtered set title: All Versions - name: x-api-key in: header required: true style: simple explode: false schema: type: string title: X-Api-Key responses: '200': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/PromptDetailResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - default: [] x-auth-type: Application & Application User x-throttling-tier: Unlimited put: tags: - prompts summary: Update Prompt Api Key description: Update an existing prompt using API key authentication. operationId: update_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts__prompt_id__put parameters: - name: prompt_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Prompt Id - name: workspace_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Workspace Id - name: x-api-key in: header required: true style: simple explode: false schema: type: string title: X-Api-Key requestBody: content: application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/Body_update_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts__prompt_id__put' responses: '200': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/PromptDetailResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - default: [] x-auth-type: Application & Application User x-throttling-tier: Unlimited delete: tags: - prompts summary: Delete Prompt Api Key description: 'Delete a prompt using API key authentication. By default performs soft delete, set hard_delete=True for permanent deletion.' operationId: delete_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts__prompt_id__delete parameters: - name: prompt_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Prompt Id - name: workspace_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Workspace Id - name: x-api-key in: header required: true style: simple explode: false schema: type: string title: X-Api-Key requestBody: content: application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/Body_delete_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts__prompt_id__delete' responses: '200': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/DeletePromptResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - default: [] x-auth-type: Application & Application User x-throttling-tier: Unlimited /v3/workspaces/{workspace_id}/generate-prompt: post: tags: - prompts summary: Post Generate Prompt V3 description: 'Generate an extraction prompt from an example document and desired output. This endpoint analyzes an example document and the expected extraction output to automatically generate a prompt that can be used for similar documents. This helps users bootstrap their extraction workflows without manually writing prompts. **Key Features:** - Accepts all supported file formats (PDF, images, text, JSON, Excel) - Validates expected output as JSON - Uses AI to generate optimized extraction prompts - Does not consume workspace quota (prompt generation is not counted) - Returns the generated prompt with metadata (tokens, costs, timestamp) **Authentication:** Requires SSO authentication with PROMPT_VIEWER role or higher. **Example Usage:** 1. Upload a sample invoice PDF 2. Provide expected output: `{"invoice_number": "INV-001", "date": "2024-01-15", "total": 1234.56}` 3. Receive a generated prompt that can extract similar fields from other invoices' operationId: post_generate_prompt_v3_v3_workspaces__workspace_id__generate_prompt_post parameters: - name: workspace_id in: path required: true style: simple explode: false schema: type: string format: uuid title: Workspace Id - name: x-auth-request-email in: header required: true style: simple explode: false schema: type: string title: X-Auth-Request-Email requestBody: content: multipart/form-data: schema: $ref: '#/components/schemas/Body_post_generate_prompt_v3_v3_workspaces__workspace_id__generate_prompt_post' required: true responses: '200': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/GeneratePromptResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - default: [] x-auth-type: Application & Application User x-throttling-tier: Unlimited components: schemas: Body_update_prompt_v3_workspaces__workspace_id__prompts__prompt_id__put: type: object properties: prompt_name: anyOf: - type: string - type: 'null' description: Updated prompt name. Leave empty to keep unchanged. example: '' title: Prompt Name prompt_content: anyOf: - type: string - type: 'null' description: Updated prompt text. Leave empty to keep unchanged. example: '' title: Prompt Content description: anyOf: - type: string - type: 'null' description: Updated description. Leave empty to keep unchanged. example: '' title: Description schema_id: anyOf: - type: string - type: 'null' description: Updated schema ID (UUID) to associate with this prompt. Use 'NO_SCHEMA' (case-insensitive) to detach any existing schema. Leave empty to keep existing schema unchanged. example: '' title: Schema Id title: Body_update_prompt_v3_workspaces__workspace_id__prompts__prompt_id__put PromptListResponse: type: object properties: prompts: type: array items: $ref: '#/components/schemas/PromptListItem' title: Prompts required: - prompts title: PromptListResponse HTTPValidationError: type: object properties: detail: type: array items: $ref: '#/components/schemas/ValidationError' title: Detail title: HTTPValidationError PromptVersionDetail: type: object properties: version_id: type: string format: uuid title: Version Id prompt_content: type: string title: Prompt Content schema_id: anyOf: - type: string format: uuid - type: 'null' title: Schema Id created_at: type: string format: date-time title: Created At updated_at: type: string format: date-time title: Updated At tags: type: array items: $ref: '#/components/schemas/TagListItem' title: Tags required: - created_at - prompt_content - schema_id - tags - updated_at - version_id title: PromptVersionDetail GeneratePromptResponse: type: object description: Response model for prompt generation endpoint. properties: generated_prompt: type: string title: Generated Prompt metadata: $ref: '#/components/schemas/FileMetadata' required: - generated_prompt - metadata title: GeneratePromptResponse ModelType: type: string enum: - flash_25_lite - flash_25_low - flash_25 - flash_3 - flash_35 - pro_25 - pro_31 - claude_haiku_45 - claude_sonnet_46 - claude_sonnet_46_low - claude_opus_46 - claude_opus_46_low - nova_2_lite - nova_2_pro_preview - nova_2_pro_preview_low title: ModelType Body_create_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts_post: type: object properties: prompt_name: type: string description: Unique name for the prompt example: Invoice Extractor title: Prompt Name prompt_content: type: string description: The prompt text/instructions for the AI model example: Extract all fields from the invoice including... title: Prompt Content description: anyOf: - type: string - type: 'null' description: Optional description of what this prompt does. Leave empty if not needed. example: '' title: Description schema_id: anyOf: - type: string - type: 'null' description: Optional schema ID (UUID) to enforce structured output. Use 'NO_SCHEMA' (case-insensitive) to explicitly not attach a schema. Leave empty if not using schema validation. example: '' title: Schema Id required: - prompt_content - prompt_name title: Body_create_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts_post TagListItem: type: object properties: name: type: string title: Name tag_id: type: string format: uuid title: Tag Id is_system: type: boolean title: Is System required: - is_system - name - tag_id title: TagListItem Body_delete_prompt_v3_workspaces__workspace_id__prompts__prompt_id__delete: type: object properties: hard_delete: type: boolean default: false description: 'Set to true for permanent deletion, false for soft delete. Default: false.' example: false title: Hard Delete title: Body_delete_prompt_v3_workspaces__workspace_id__prompts__prompt_id__delete PromptListItem: type: object properties: name: type: string title: Name prompt_id: type: string format: uuid title: Prompt Id required: - name - prompt_id title: PromptListItem Body_update_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts__prompt_id__put: type: object properties: prompt_name: anyOf: - type: string - type: 'null' description: Updated prompt name. Leave empty to keep unchanged. example: '' title: Prompt Name prompt_content: anyOf: - type: string - type: 'null' description: Updated prompt text. Leave empty to keep unchanged. example: '' title: Prompt Content description: anyOf: - type: string - type: 'null' description: Updated description. Leave empty to keep unchanged. example: '' title: Description schema_id: anyOf: - type: string - type: 'null' description: Updated schema ID (UUID) to associate with this prompt. Use 'NO_SCHEMA' (case-insensitive) to detach any existing schema. Leave empty to keep existing schema unchanged. example: '' title: Schema Id title: Body_update_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts__prompt_id__put Body_post_generate_prompt_v3_v3_workspaces__workspace_id__generate_prompt_post: type: object properties: file: type: string format: binary description: The example document file to use as reference (PDF, DOCX, TXT, images, JSON, Excel, etc.) title: File expected_output: type: string description: JSON string representing the desired extraction output structure. This defines what information should be extracted from similar documents. Must be valid JSON. example: '{"invoice_number": "INV-001", "total": 1234.56}' title: Expected Output required: - expected_output - file title: Body_post_generate_prompt_v3_v3_workspaces__workspace_id__generate_prompt_post FileMetadata: type: object properties: uuid: anyOf: - type: string - type: 'null' title: Uuid request_id: anyOf: - type: string - type: 'null' title: Request Id model_type: $ref: '#/components/schemas/ModelType' input_tokens: type: integer title: Input Tokens output_tokens: type: integer title: Output Tokens thinking_tokens: anyOf: - type: integer - type: 'null' title: Thinking Tokens token_costs: type: number title: Token Costs processed_at: type: string title: Processed At finish_reason: anyOf: - type: string - type: 'null' title: Finish Reason finish_message: anyOf: - type: string - type: 'null' title: Finish Message tool_calls: type: array default: [] items: type: string title: Tool Calls processing_time_ms: anyOf: - type: integer - type: 'null' title: Processing Time Ms required: - input_tokens - model_type - output_tokens - processed_at - token_costs title: FileMetadata Body_create_prompt_v3_workspaces__workspace_id__prompts_post: type: object properties: prompt_name: type: string description: Unique name for the prompt example: Invoice Extractor title: Prompt Name prompt_content: type: string description: The prompt text/instructions for the AI model example: Extract all fields from the invoice including... title: Prompt Content description: anyOf: - type: string - type: 'null' description: Optional description of what this prompt does. Leave empty if not needed. example: '' title: Description schema_id: anyOf: - type: string - type: 'null' description: Optional schema ID (UUID) to enforce structured output. Use 'NO_SCHEMA' (case-insensitive) to explicitly not attach a schema. Leave empty if not using schema validation. example: '' title: Schema Id required: - prompt_content - prompt_name title: Body_create_prompt_v3_workspaces__workspace_id__prompts_post PromptDetailResponse: type: object properties: name: type: string title: Name prompt_id: type: string format: uuid title: Prompt Id prompt_text: type: string title: Prompt Text schema_id: anyOf: - type: string format: uuid - type: 'null' title: Schema Id workspace_id: type: string format: uuid title: Workspace Id description: anyOf: - type: string - type: 'null' title: Description created_at: type: string format: date-time title: Created At updated_at: type: string format: date-time title: Updated At prompt_version_id: type: string format: uuid title: Prompt Version Id version_tag: type: string title: Version Tag versions: type: array items: $ref: '#/components/schemas/PromptVersionDetail' title: Versions required: - created_at - description - name - prompt_id - prompt_text - prompt_version_id - schema_id - updated_at - version_tag - versions - workspace_id title: PromptDetailResponse Body_delete_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts__prompt_id__delete: type: object properties: hard_delete: type: boolean default: false description: 'Set to true for permanent deletion, false for soft delete. Default: false.' example: false title: Hard Delete title: Body_delete_prompt_api_key_v3_api_key_auth_workspaces__workspace_id__prompts__prompt_id__delete DeletePromptResponse: type: object description: Response model for prompt deletion. properties: success: type: boolean title: Success prompt_id: type: string format: uuid title: Prompt Id required: - prompt_id - success title: DeletePromptResponse ValidationError: type: object properties: loc: type: array items: anyOf: - type: string - type: integer title: Location msg: type: string title: Message type: type: string title: Error Type input: title: Input ctx: type: object title: Context required: - loc - msg - type title: ValidationError securitySchemes: default: type: oauth2 flows: implicit: authorizationUrl: https://gateway.api.kuehne-nagel.com/authorize scopes: {} x-wso2-api-key-header: ApiKey