Best Practices

Best Practices in API

API Implementation Standards

  1. Pre-Production Testing
    Always validate API requests in Postman or the built-in API Explorer before integration
    Test environments should mirror production configurations

  2. Document Operations

    OperationEndpointSpecial Requirements
    Add Document/docaddRequires meta tags
    Delete Document/docdeleteUID must exist
    Update Metadata/updatemetadataSupports custom fields

    Critical Notes:
    File collection paths must use forward slashes (/) exclusively
    Form authentication only works through docadd for WEB collections
    Metadata is mandatory in add operations

  3. Authentication & Headers
    SB-PKEY header is required for all requests
    API keys should be:
    Rotated quarterly
    Stored securely (never in client-side code)
    Restricted by IP when possible

  4. Error Handling

    CodeTypical Resolution
    400Validate JSON structure and required fields
    401Verify SB-PKEY matches Admin Console
    404Confirm collection/document exists
    500Check server logs and retry with backoff
  5. URL Validation
    Implement pre-flight checks for all provided URLs
    Reject malformed URLs before API submission

  6. Advanced Recommendations
    Performance Optimization
    Batch processing: Limit to 100 documents/request
    Throttling: Implement 500ms delay between requests
    Connection reuse: Maintain persistent HTTP connections


Troubleshooting Checklist

  1. Verify SB-PKEY matches Admin Console
  2. Confirm collection exists
  3. Validate JSON payload structure
  4. Check network connectivity to SearchBlox server
  5. Review server logs for detailed errors

🚧

Note:

  • It is required to use SB-PKEY to attempt all SearchBlox REST API requests.
  • SB-PKEY can be found on Dashboard->Administration->Users under the Private Key tab for each Admin role user.
  • Admin role users will have access to Unique SB-PKEY.