GET
/
api
/
get-scripts
Get User Scripts
curl --request GET \
  --url https://onlyautomator.com/api/get-scripts \
  --header 'Authorization: <authorization>'
{
  "status": 200,
  "message": "Scripts retrieved successfully",
  "folders": [
    {
      "id": "script_uuid_1",
      "user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "folder_id": "folder_123",
      "name": "My Welcome Script",
      "text": "Hello {{fan_name}}!",
      "created_at": "2023-11-07T05:31:56Z"
    }
  ]
}
Fetches all script records from the scripts table that belong to the currently authenticated user.

Authentication

This endpoint requires authentication via bearer token representing a valid user session managed by Supabase Auth (cookies).Testing Note: Requires user session.
Retrieving JWT Token: (Refer to other endpoints for instructions)

Request

Authorization
string
required
Bearer token for authentication. Format: Bearer YOUR_JWT_TOKEN

Response

status
number
HTTP status code (e.g., 200).
message
string
A descriptive message about the result (e.g., “Scripts retrieved successfully”).
folders
array
An array containing the user’s script objects from the scripts table. Note: The key name folders seems potentially confusing, it actually contains scripts.

Error Codes

Status CodeDescriptionExample Message
401Invalid or missing authentication token.”Unauthorized”
500Internal server error during processing.”Failed to get scripts”
500Database error during fetch.Specific DB error

Notes

  • Retrieves all scripts belonging to the authenticated user.
  • Assumes a scripts table exists.

Code Examples

// Using fetch
const getUserScripts = async (apiToken) => {
  const response = await fetch(`https://onlyautomator.com/api/get-scripts`, {
    method: 'GET',
    headers: {
      'Authorization': `Bearer ${apiToken}`
    }
  });

  if (!response.ok) {
     const errorData = await response.json();
     throw new Error(`API Error (${response.status}): ${errorData.error || 'Unknown error'}`);
  }
  return await response.json();
};

// Example usage
getUserScripts('your_api_token')
  .then(data => console.log('User scripts:', data.folders)) // Note the key is 'folders'
  .catch(error => console.error('Error fetching scripts:', error));

Headers

Authorization
string
required

Bearer token for authentication (JWT)

Response

Scripts retrieved successfully.

status
number
Example:

200

message
string
Example:

"Scripts retrieved successfully"

folders
object[]