Using the API

Below is an overview of Sysprompt’s public API—an alternative to using the SDK for creating and managing prompts or retrieving prompt logs. All requests require an API Key passed in the request header, ensuring secure access to your Sysprompt data.

Authentication

To authenticate, include your API Key in the header as X-PROJECT-KEY. For example:

curl -H "X-PROJECT-KEY: your-api-key-here" https://api.sysprompt.com/endpoint

You can generate or view your API Key in your Sysprompt account settings.

Endpoints
1. Process a Prompt Execution Log

POST /v1/sdk/logs/prompt/

  • Use Case: Record or process a prompt’s execution details (e.g., logging usage statistics or capturing output).
  • Request Body: Typically includes data about the prompt execution, though the exact structure may vary based on your logging requirements.
  • Example (cURL):

    curl -X POST https://api.sysprompt.com/v1/sdk/logs/prompt/ \
         -H "X-PROJECT-KEY: your-api-key-here" \
         -d '{
           "prompt_code": "untitled_T1iqKwGtIvpw",
           "executed_at": "2025-01-15T10:00:00Z",
           "additional_data": "Your custom log info"
         }'
    

    2. Get the List of Prompts

    GET /v1/sdk/prompts/

  • Use Case: Retrieve all available prompts associated with your project/API Key.
  • Response: Returns a JSON array containing prompt metadata (e.g., code_id, name, creation date).
  • Example (cURL):

    curl -X GET https://api.sysprompt.com/v1/sdk/prompts/ \
         -H "X-PROJECT-KEY: your-api-key-here"
    

    3. Create a New Prompt

    POST /v1/sdk/prompts/

  • Use Case: Create a fresh prompt directly via the API instead of using the Sysprompt UI.
  • Request Body: Provide details like prompt content, title, and any relevant metadata
  • Example (cURL):

    curl -X POST https://api.sysprompt.com/v1/sdk/prompts \
         -H "X-PROJECT-KEY: your-api-key-here" \
         -d '{
           "name": "NewPromptTitle",
           "content": "Your prompt text here with {{variables}} if needed."
         }'
    

    4. Get a Specific Prompt by Code ID

    GET /v1/sdk/prompts/{code_id}/

  • Use Case: Fetch a single prompt and its details using the code_id.
  • Response: Returns the prompt content and metadata.
  • Example (cURL):

    curl -X GET https://api.sysprompt.com/v1/sdk/prompts/untitled_T1iqKwGtIvpw/ \
         -H "X-PROJECT-KEY: your-api-key-here"
    

    4. Get a Specific Prompt by Code ID

    GET /v1/sdk/prompts/{code_id}/

  • Use Case: Fetch a single prompt and its details using the code_id.
  • Response: Returns the prompt content and metadata.
  • Example (cURL):

    curl -X GET https://api.sysprompt.com/v1/sdk/prompts/untitled_T1iqKwGtIvpw/ \
         -H "X-PROJECT-KEY: your-api-key-here"
    

    Tips for Working with the API

    Working with the Sysprompt API effectively involves a few key considerations to ensure security, reliability, and maintainability. Below are some best practices to keep in mind:

  • Secure Your API Key: Treat your X-PROJECT-KEY as a secret; never expose it in client-side code or public repositories.
  • Use the Correct Endpoint Versions: Sysprompt’s API is versioned (/v1/sdk/...). Always use the latest stable path to avoid compatibility issues.
  • Handle Errors Gracefully: The API returns standard HTTP status codes. Check for non-2xx responses, and implement proper error handling or retries in your integration.
  • Combine with Variables: If you’re creating or updating prompts containing placeholders like {{variable_name}}, pass them correctly in your JSON. This ensures your prompts remain flexible and dynamic.
  • Keep Data Consistent: When logging prompt executions or updating prompts, use consistent field names and structures so the data is easier to parse, analyze, and maintain.
  • Need support?
    Contact us

    Ready to get started?

    Take the first step to growing your business
    Get started