Authentication
Dify sends the API Key you configured as a Bearer token in every request:Request
/retrieval to the endpoint URL you configured. If you registered https://your-service.com, Dify sends requests to https://your-service.com/retrieval.
Body
retrieval_setting
metadata_condition
Dify passes metadata conditions to your API but does not currently provide a UI for users to configure them. This parameter is available for programmatic use only.
Each object in
conditions:
Supported Comparison Operators
Supported Comparison Operators
Example Request
Response
Return HTTP 200 with a JSON body containing arecords array. If no results match the query, return an empty array: {"records": []}.
records
Dify does not reject records with missing fields, but omitting
content or score will produce incomplete or unranked results.
Example Response
Error Handling
Dify checks the HTTP status code of your response. A non-200 status raises an error that surfaces to the user. You can optionally return structured error information in JSON:
The following are suggested error codes. These are conventions, not enforced by Dify: