Best Practices
Best Practices in API
API Implementation Standards
-
Pre-Production Testing
Always validate API requests in Postman or the built-in API Explorer before integration
Test environments should mirror production configurations -
Document Operations
Operation Endpoint Special Requirements Add Document /docadd
Requires meta tags Delete Document /docdelete
UID must exist Update Metadata /updatemetadata
Supports 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 -
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 -
Error Handling
Code Typical Resolution 400 Validate JSON structure and required fields 401 Verify SB-PKEY matches Admin Console 404 Confirm collection/document exists 500 Check server logs and retry with backoff -
URL Validation
Implement pre-flight checks for all provided URLs
Reject malformed URLs before API submission -
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
- Verify SB-PKEY matches Admin Console
- Confirm collection exists
- Validate JSON payload structure
- Check network connectivity to SearchBlox server
- 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.
Updated 10 days ago