Skip to main content

Projects API

List of Projects

Shell
curl -X GET "https://scriptrun.ai/api/v1/projects/?page=1&size=10&name__icontains=test" \
-H "X-Api-Key: <Your API Key>"
Python
import requests

url = "https://scriptrun.ai/api/v1/projects/"
headers = \{"X-Api-Key": "<Your API Key>"\}
params = \{"page": 1, "size": 10, "name__icontains": "test"\}

response = requests.get(url, headers=headers, params=params)
print(response.json())

GET /api/v1/projects/

Summary: Retrieves a list of projects. Projects track expenses related to rendering prompts and may include various plans (e.g., JustmagicPlan) as well as webhook configurations.

Parameters:

NameInTypeRequiredDescription
name__icontainsquerystringNoFilter projects by name (case-insensitive match).
pagequeryintegerNoA page number within the paginated result set.
sizequeryintegerNoNumber of results to return per page.

Responses:

  • 200 OK:
    • Content-Type: application/json
      • Schema:
        • page (integer) Required: Page of query.
        • size (integer) Optional: Number of results per call. Accepted values: 0 - 100. Default 10.
        • total (integer) Optional: Total objects in query.
        • items (array) Required: List of projects.

Create a Project

Shell
curl -X POST "https://scriptrun.ai/api/v1/projects/" \
-H "X-Api-Key: <Your API Key>" \
-H "Content-Type: application/json" \
-d '\{"name": "New Project", "webhook_url": "https://example.com/webhook/"\}'
Python
import requests

url = "https://scriptrun.ai/api/v1/projects/"
headers = {
"X-Api-Key": "<Your API Key>",
"Content-Type": "application/json"
}
data = {
"name": "New Project",
"webhook_url": "https://example.com/webhook/"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())

POST /api/v1/projects/

Summary: Creates a new project. A project tracks expenses for prompt rendering and includes webhook settings and various plans.

Request Body:

  • Content-Type: application/json
  • Schema:
    • id (integer) Required: Unique identifier for the project.
    • name (string) Required: Name of the project.
    • total_spent (number) Optional: Total amount spent on the project.
    • webhook_url (string) Optional: URL for project webhook notifications.
    • is_webhook_enabled (boolean) Optional: Whether the webhook is enabled.

Responses:

  • 201 Created:
    • Content-Type: application/json
      • Schema:
        • id (integer) Required: ID of the newly created project.
        • name (string) Required: Name of the project.
        • total_spent (number) Optional: Total spent on the project.
        • created_at (string) Required: Timestamp when the project was created.
        • updated_at (string) Required: Timestamp when the project was last updated.
        • webhook_url (string) Optional: Webhook URL for the project.
        • is_webhook_enabled (boolean) Optional: Whether the webhook is enabled.

Retrieve a Project

Shell
curl -X GET "https://scriptrun.ai/api/v1/projects/123/" \
-H "X-Api-Key: <Your API Key>"
Python
import requests

url = "https://scriptrun.ai/api/v1/projects/123/"
headers = \{"X-Api-Key": "<Your API Key>"\}

response = requests.get(url, headers=headers)
print(response.json())

GET /api/v1/projects/\\{id}/`

Summary: Retrieves the details of a specific project, including its name, plan, and webhook configuration.

Parameters:

NameInTypeRequiredDescription
idpathintegerYesA unique integer value identifying the project.

Responses:

  • 200 OK:
    • Content-Type: application/json
      • Schema:
        • id (integer) Required: Unique ID of the project.
        • name (string) Required: Name of the project.
        • total_spent (number) Optional: Total spent on the project.
        • created_at (string) Required: Timestamp when the project was created.
        • updated_at (string) Required: Timestamp when the project was last updated.
        • webhook_url (string) Optional: Webhook URL for notifications.
        • is_webhook_enabled (boolean) Optional: Whether the webhook is enabled.

Update a Project

Shell
curl -X PATCH "https://scriptrun.ai/api/v1/projects/123/" \
-H "X-Api-Key: <Your API Key>" \
-H "Content-Type: application/json" \
-d '\{"name": "Updated Project", "webhook_url": "https://example.com", "is_webhook_enabled": true\}'
Python
import requests

url = "https://scriptrun.ai/api/v1/projects/123/"
headers = {
"X-Api-Key": "<Your API Key>",
"Content-Type": "application/json"
}
data = {
"name": "Updated Project",
"is_webhook_enabled": True,
"webhook_url": "https://example.com"
}

response = requests.patch(url, headers=headers, json=data)
print(response.json())

PATCH /api/v1/projects/\\{id}/`

Summary: Updates the details of a specific project. Only certain fields such as name, total_spent, webhook_url, or is_webhook_enabled can be updated.

Parameters:

NameInTypeRequiredDescription
idpathintegerYesA unique integer value identifying the project.

Request Body:

  • Content-Type: application/json
  • Schema:
    • name (string) Optional: New name for the project.
    • webhook_url (string) Optional: Updated webhook URL.
    • is_webhook_enabled (boolean) Optional: Whether the webhook is enabled.

Responses:

  • 200 OK:
    • Content-Type: application/json
      • Schema:
        • id (integer) Required: ID of the updated project.
        • name (string) Required: Name of the project.
        • webhook_url (string) Optional: Updated webhook URL.
        • is_webhook_enabled (boolean) Optional: Whether the webhook is enabled.

Delete a Project

Shell
curl -X DELETE "https://scriptrun.ai/api/v1/projects/123/" \
-H "X-Api-Key: <Your API Key>"
Python
import requests

url = "https://scriptrun.ai/api/v1/projects/123/"
headers = \{"X-Api-Key": "<Your API Key>"\}

response = requests.delete(url, headers=headers)
print(response.status_code) # 204 indicates success

DELETE /api/v1/projects/\\{id}/`

Summary: Deletes a specific project by its ID.

Parameters:

NameInTypeRequiredDescription
idpathintegerYesA unique integer value identifying the project.

Responses:

  • 204 No Content: No response body.