### Install GoHighLevel Python SDK Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Installs the GoHighLevel Python SDK using pip. This is the first step to using the library in your Python projects. ```bash pip install gohl ``` -------------------------------- ### Get, Create, Update, and Delete Calendars (Python) Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Provides Python code examples for managing calendars within GoHighLevel, including retrieving all calendars for a location, fetching a specific calendar, creating a new one with availability, updating existing calendars, and deleting them. Requires 'gohl' and authentication. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Get all calendars for a location calendars = ghl.calendar.get_all( location_id="loc_abc123", show_drafted=True ) for cal in calendars: print(f"Calendar: {cal['name']} (ID: {cal['id']})") # Get a specific calendar calendar = ghl.calendar.get(calendar_id="cal_xyz789") print(f"Calendar details: {calendar['name']}") # Create a new calendar new_calendar = ghl.calendar.add({ "name": "Sales Team Calendar", "description": "Calendar for sales team appointments", "locationId": "loc_abc123", "teamMembers": ["user_1", "user_2"], "slotDuration": 30, "slotInterval": 15, "availableHours": { "monday": [{"start": "09:00", "end": "17:00"}], "tuesday": [{"start": "09:00", "end": "17:00"}], "wednesday": [{"start": "09:00", "end": "17:00"}], "thursday": [{"start": "09:00", "end": "17:00"}], "friday": [{"start": "09:00", "end": "17:00"}] } }) print(f"Created calendar: {new_calendar['id']}") # Update a calendar updated_calendar = ghl.calendar.update( calendar_id=new_calendar['id'], calendar={ "name": "Updated Sales Calendar", "slotDuration": 45 } ) print(f"Updated calendar: {updated_calendar['name']}") # Delete a calendar deleted = ghl.calendar.remove(calendar_id=new_calendar['id']) print(f"Calendar deleted: {deleted}") ``` -------------------------------- ### Access Available API Endpoints (Python) Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Illustrates how to initialize the GoHighLevel SDK and provides commented-out examples for accessing various API endpoints such as blogs, businesses, campaigns, and more. Requires API key for initialization. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Blogs API # ghl.blogs - Manage blog posts and content # Business API # ghl.businesses - Manage business profiles # Campaigns API # ghl.campaigns - Manage marketing campaigns # Company API # ghl.company - Access company information # Courses API # ghl.courses - Manage online courses # Custom Fields API # ghl.custom_fields - Manage custom fields # Custom Menus API # ghl.custom_menus - Manage custom menus # Email API # ghl.email - Email management # Surveys API # ghl.surveys - Manage surveys # SaaS API # ghl.saas - SaaS management features # Snapshots API # ghl.snapshots - Manage account snapshots # Sub-accounts API # ghl.subaccounts - Manage sub-accounts # Trigger Links API # ghl.links - Manage trigger links # Agency APIs # ghl.agency['locations'] - Manage agency locations # ghl.agency['users'] - Manage agency users ``` -------------------------------- ### Initialize GoHighLevel API with API Key Source: https://github.com/m2kdevelopments/gohighlevel-py/blob/main/README.md Demonstrates how to initialize the GoHighLevel client using an API key for authentication. This is the simplest way to start interacting with the API if you have an API key. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials=Credentials(api_key="***") ghl = GoHighLevel(credentials=credentials) ``` -------------------------------- ### Manage Calendars and Events Source: https://github.com/m2kdevelopments/gohighlevel-py/blob/main/README.md Provides examples for managing calendars, including fetching all calendars, creating new ones, retrieving events, creating appointments, and managing calendar groups, resources, and notifications. ```python # Get all calendars for a location calendars = ghl.calendar.get_all(location_id="your_location_id") # Create a new calendar new_calendar = ghl.calendar.add({ "name": "Team Meetings", "description": "Calendar for team meetings", "locationId": "your_location_id" }) # Get calendar events events = ghl.calendar.events.get_all( location_id="your_location_id", start_time="2024-01-01T00:00:00Z", end_time="2024-01-31T23:59:59Z" ) # Create an appointment appointment = ghl.calendar.events.add_appointment( location_id="your_location_id", contact_id="contact_id", start_time="2024-01-15T10:00:00Z", calendar={ "title": "Project Review", "duration": 60, "calendarId": "calendar_id" } ) # Manage calendar groups groups = ghl.calendar.groups.get_all() new_group = ghl.calendar.groups.add({ "name": "Sales Team", "description": "Calendar group for sales team", "locationId": "your_location_id" }) # Manage calendar resources rooms = ghl.calendar.resources.get_all(resource_type="rooms") new_room = ghl.calendar.resources.add( resource_type="rooms", resource={ "name": "Conference Room A", "capacity": 20, "locationId": "your_location_id" } ) # Manage calendar notifications notifications = ghl.calendar.notifications.get_all( calendar_id="calendar_id", extra={ "is_active": True, "limit": 10 } ) # Create appointment notes note = ghl.calendar.appointmentnotes.add( appointment_id="appointment_id", body="Meeting notes: Discussed project timeline", user_id="user_id" ) ``` -------------------------------- ### Manage GoHighLevel Forms (Python) Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Retrieve all forms for a location or get details of a specific form using the GoHighLevel Python SDK. Requires authentication. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Get all forms forms = ghl.forms.get_all( location_id="loc_abc123", limit=50, skip=0 ) for form in forms: print(f"Form: {form['name']} (ID: {form['id']})") # Get a specific form form = ghl.forms.get(form_id="form_xyz789") print(f"Form fields: {form.get('fields')}") ``` -------------------------------- ### Create, Update, Get, and Delete Contacts (Python) Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Shows how to create new contacts, update existing ones, retrieve a single contact by ID, and delete a contact using the GoHighLevel Python SDK. Requires the 'gohl' library and authentication credentials. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Create a new contact new_contact = ghl.contacts.create( contact={ "firstName": "John", "lastName": "Doe", "email": "john.doe@example.com", "phone": "+1234567890", "company": "Acme Corp", "address1": "123 Main St", "city": "New York", "state": "NY", "postalCode": "10001", "source": "Website Form", "tags": ["new-lead", "website"], "customFields": { "industry": "Technology", "company_size": "50-100" } }, location_id="loc_abc123" ) print(f"Created contact: {new_contact['id']}") # Update the contact updated_contact = ghl.contacts.update( id=new_contact['id'], contact={ "firstName": "John", "lastName": "Smith", "tags": ["new-lead", "website", "contacted"], "customFields": { "last_contact_date": "2024-01-15" } } ) print(f"Updated contact: {updated_contact['firstName']} {updated_contact['lastName']}") # Get a single contact by ID contact = ghl.contacts.get_one(contact_id=new_contact['id']) print(f"Contact details: {contact}") # Delete a contact success = ghl.contacts.remove(id=new_contact['id']) print(f"Contact deleted: {success}") ``` -------------------------------- ### Get GoHighLevel Opportunity Analytics (Python) Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Retrieve analytics and insights for opportunities within a specified date range and pipeline. Requires the gohl library and authentication. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Get opportunity analytics analytics = ghl.opportunities.get_analytics( location_id="loc_abc123", pipeline_id="pipe_sales", start_date="2024-01-01T00:00:00Z", end_date="2024-03-31T23:59:59Z" ) print(f"Pipeline Analytics: {analytics}") print(f" Total deals: {analytics.get('totalDeals')}") print(f" Total value: ${analytics.get('totalValue')}") print(f" Won deals: {analytics.get('wonDeals')}") print(f" Conversion rate: {analytics.get('conversionRate')}") ``` -------------------------------- ### Get Workflows for a Location (Python) Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Retrieves all automation workflows associated with a specific GoHighLevel location. Requires authentication credentials and a valid location ID. Outputs the name, ID, status, and triggers for each workflow. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Get all workflows for a location workflows = ghl.workflows.get_all(location_id="loc_abc123") for workflow in workflows: print(f"Workflow: {workflow['name']}") print(f" ID: {workflow['id']}") print(f" Status: {workflow.get('status')}") print(f" Triggers: {workflow.get('triggers')}") ``` -------------------------------- ### Get Conversation Providers Source: https://github.com/m2kdevelopments/gohighlevel-py/blob/main/README.md Retrieves a list of conversation providers for a given location. ```APIDOC ## GET /conversations/providers ### Description Retrieves a list of conversation providers for a given location. ### Method GET ### Endpoint `/conversations/providers` ### Parameters #### Path Parameters None #### Query Parameters - **location_id** (string) - Required - The ID of the location to get providers for. ### Request Example ```json { "location_id": "your_location_id" } ``` ### Response #### Success Response (200) - **providers** (array of objects) - A list of conversation providers. - **id** (string) - The provider ID. - **name** (string) - The provider name. #### Response Example ```json { "providers": [ { "id": "provider_1", "name": "Provider One" } ] } ``` ``` -------------------------------- ### Get Conversation Providers using GoHighLevel Python SDK Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Retrieves a list of available conversation providers for a given location using the GoHighLevel Python SDK. Requires location ID. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Get all conversation providers for a location providers = ghl.conversations.providers.get_all(location_id="loc_abc123") for provider in providers: print(f"Provider: {provider.get('name')} - Type: {provider.get('type')}") ``` -------------------------------- ### Manage Calendar Events and Appointments - Python Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Provides functionality to get all events within a date range, create, update, and delete appointments, and manage block slots. Requires location ID, contact ID, event IDs, and calendar details for specific operations. Returns created/updated appointment details or confirmation of deletion. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Get all events in a date range events = ghl.calendar.events.get_all( location_id="loc_abc123", start_time="2024-01-01T00:00:00Z", end_time="2024-01-31T23:59:59Z", extra={ "userId": "user_123", "calendarId": "cal_xyz789" } ) for event in events: print(f"Event: {event.get('title')} at {event.get('startTime')}") # Create an appointment appointment = ghl.calendar.events.add_appointment( location_id="loc_abc123", contact_id="contact_abc123", start_time="2024-01-20T10:00:00Z", calendar={ "title": "Sales Discovery Call", "calendarId": "cal_xyz789", "appointmentStatus": "confirmed", "notes": "Discuss product requirements", "address": "Virtual - Zoom", "assignedUserId": "user_123" } ) print(f"Created appointment: {appointment}") # Update an appointment updated_appointment = ghl.calendar.events.update_appointment( event_id="event_abc123", event={ "title": "Updated: Sales Discovery Call", "notes": "Updated meeting notes", "appointmentStatus": "confirmed" } ) print(f"Updated appointment: {updated_appointment}") # Get block slots block_slots = ghl.calendar.events.get_block_slots( location_id="loc_abc123", start_time="2024-01-01T00:00:00Z", end_time="2024-01-31T23:59:59Z" ) print(f"Found {len(block_slots)} block slots") # Create a block slot block_slot = ghl.calendar.create_block_slot( location_id="loc_abc123", start_time="2024-01-22T12:00:00Z", end_time="2024-01-22T13:00:00Z", extra={ "calendarId": "cal_xyz789", "title": "Lunch Break", "assignedUserId": "user_123" } ) print(f"Created block slot: {block_slot}") # Delete an event deleted = ghl.calendar.events.remove(event_id="event_abc123") print(f"Event deleted: {deleted}") ``` -------------------------------- ### Get Conversation Providers via GoHighLevel Python SDK Source: https://github.com/m2kdevelopments/gohighlevel-py/blob/main/README.md Retrieves all available conversation providers for a given location. Requires a location ID. This is useful for understanding available communication channels. ```python providers = ghl.conversations.providers.get_all(location_id="your_location_id") ``` -------------------------------- ### Get Free Calendar Slots - Python Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Retrieves available time slots for scheduling within a specified date range for a given calendar. Requires calendar ID, start/end timestamps, timezone, and user ID. Returns a list of available slots. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials import time credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Get free slots for a calendar # Timestamps in milliseconds start_timestamp = int(time.time() * 1000) end_timestamp = start_timestamp + (7 * 24 * 60 * 60 * 1000) # 7 days ahead free_slots = ghl.calendar.get_free_slots( calendar_id="cal_xyz789", start_date=start_timestamp, end_date=end_timestamp, timezone="America/New_York", user_id="user_123" ) print(f"Available slots: {free_slots}") ``` -------------------------------- ### Get Free Slots Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Retrieve available time slots for scheduling from a specific calendar. This function requires calendar ID, start and end timestamps, timezone, and user ID. ```APIDOC ## GET /calendars/{calendar_id}/free_slots ### Description Find available time slots for scheduling. ### Method GET ### Endpoint `/calendars/{calendar_id}/free_slots` ### Parameters #### Query Parameters - **calendar_id** (string) - Required - The ID of the calendar to check for free slots. - **start_date** (integer) - Required - The start timestamp (in milliseconds) for the date range. - **end_date** (integer) - Required - The end timestamp (in milliseconds) for the date range. - **timezone** (string) - Required - The timezone for the date range (e.g., "America/New_York"). - **user_id** (string) - Optional - The ID of the user associated with the calendar. ### Response #### Success Response (200) - **slots** (array) - A list of available time slots. #### Response Example ```json { "slots": [ "2024-01-20T09:00:00Z", "2024-01-20T11:00:00Z" ] } ``` ``` -------------------------------- ### Manage GoHighLevel Products (Python) Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Create, retrieve, update, and delete products in GoHighLevel. Supports listing products with filtering and sorting. Requires the gohl library. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # List all products products = ghl.products.get_all(params={ "page": 1, "limit": 25, "active": True, "sort": "name", "order": "asc" }) for product in products.get('products', []): print(f"Product: {product['name']} - ${product.get('price')}") # Get a specific product product = ghl.products.get(product_id="prod_xyz789") print(f"Product details: {product}") # Create a new product new_product = ghl.products.create(data={ "name": "Premium Consulting Package", "description": "10 hours of premium consulting services", "price": 2500.00, "currency": "USD", "type": "service", "active": True, "locationId": "loc_abc123", "customFields": { "hours_included": "10", "validity": "90 days" } }) print(f"Created product: {new_product}") # Update a product updated_product = ghl.products.update( product_id="prod_xyz789", data={ "price": 2750.00, "description": "Updated: 10 hours of premium consulting with priority support" } ) print(f"Updated product: {updated_product}") # Delete a product deleted = ghl.products.delete(product_id="prod_old123") print(f"Product deleted: {deleted}") ``` -------------------------------- ### Initialize GoHighLevel SDK with API Key Authentication Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Initializes the GoHighLevel SDK using an API key for direct authentication. This method is suitable for simple integrations where an API key is readily available. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials # Initialize with API key for direct access credentials = Credentials(api_key="your_api_key_here") ghl = GoHighLevel(credentials=credentials) # Now you can access all endpoints contacts = ghl.contacts.search(query="john", limit=10) print(f"Found {contacts['total']} contacts") ``` -------------------------------- ### Manage Media Library with Python Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt This snippet shows how to manage files and folders within the GoHighLevel media library using the Python SDK. It covers retrieving, uploading, updating, and deleting files, as well as managing folders. Requires an initialized GoHighLevel client. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Get all media files files = ghl.medialibrary.get_all_files( location_id="loc_abc123", folder_id="folder_images", limit=50, skip=0 ) for file in files: print(f"File: {file['name']} - Type: {file.get('type')}") # Get a specific file file = ghl.medialibrary.get_file(file_id="file_xyz789") print(f"File URL: {file.get('url')}") # Upload a new file with open("product_image.jpg", "rb") as f: uploaded_file = ghl.medialibrary.upload_file( location_id="loc_abc123", file=f, metadata={ "name": "Product Hero Image", "description": "Main product showcase image for landing page", "folderId": "folder_products", "type": "image", "tags": ["product", "hero", "landing-page"], "metadata": { "dimensions": "1920x1080", "format": "jpg", "usage": "website-header" } } ) print(f"Uploaded file: {uploaded_file['id']}") # Update file metadata updated_file = ghl.medialibrary.update_file( file_id="file_xyz789", data={ "name": "Updated Product Image", "description": "Updated description", "tags": ["product", "updated", "2024"] } ) print(f"Updated file: {updated_file['name']}") # Delete a file deleted = ghl.medialibrary.delete_file(file_id="file_old123") print(f"File deleted: {deleted}") # Get all folders folders = ghl.medialibrary.get_all_folders( location_id="loc_abc123", parent_id=None, # Root folders limit=50, skip=0 ) for folder in folders: print(f"Folder: {folder['name']}") # Create a new folder new_folder = ghl.medialibrary.create_folder( location_id="loc_abc123", folder={ "name": "Marketing Assets 2024", "description": "All marketing materials for 2024 campaigns", "parentId": "folder_marketing", "permissions": { "admin": ["read", "write", "delete"], "marketing": ["read", "write"], "sales": ["read"] } } ) print(f"Created folder: {new_folder['id']}") ``` -------------------------------- ### Update and Delete Media Library Folders (Python) Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Demonstrates how to update an existing media library folder by providing its ID and new data, and how to delete a folder using its ID. Assumes the `ghl` object is initialized. ```python updated_folder = ghl.medialibrary.update_folder( folder_id=new_folder['id'], data={ "name": "Marketing Assets Q1 2024", "description": "Updated folder description" } ) print(f"Updated folder: {updated_folder['name']}") deleted = ghl.medialibrary.delete_folder(folder_id="folder_old123") print(f"Folder deleted: {deleted}") ``` -------------------------------- ### Search and Retrieve Contacts using GoHighLevel SDK Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Demonstrates how to search for contacts using various parameters like query, order, sort_by, and limit. It also shows how to look up contacts by email or phone number and retrieve contacts associated with a specific business ID. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Simple search results = ghl.contacts.search( query="john", order="desc", sort_by="date_added", limit=20 ) print(f"Found {results['total']} contacts") for contact in results['contacts']: print(f" - {contact.get('firstName')} {contact.get('lastName')}: {contact.get('email')}") # Lookup by email or phone (API key only) contacts = ghl.contacts.lookup(email="john.doe@example.com") print(f"Found {len(contacts)} matching contacts") # Get contacts by business ID business_contacts = ghl.contacts.get_by_business_id(business_id="business_abc123") print(f"Business has {business_contacts['total']} contacts") ``` -------------------------------- ### Manage GoHighLevel Forms with Python Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt This snippet demonstrates how to create, update, retrieve submissions for, and delete forms using the GoHighLevel Python SDK. It requires a GoHighLevel client instance initialized with credentials. ```python from gohl import GoHighLevel # Assuming ghl is an initialized GoHighLevel client instance # ghl = GoHighLevel(credentials=...) # Create a new form new_form = ghl.forms.add( location_id="loc_abc123", fields=[ { "name": "first_name", "label": "First Name", "type": "text", "required": True, "placeholder": "Enter your first name" }, { "name": "last_name", "label": "Last Name", "type": "text", "required": True, "placeholder": "Enter your last name" }, { "name": "email", "label": "Email Address", "type": "email", "required": True, "placeholder": "you@example.com" }, { "name": "phone", "label": "Phone Number", "type": "phone", "required": False, "placeholder": "+1 (555) 000-0000" }, { "name": "interest", "label": "Area of Interest", "type": "select", "required": True, "options": ["Consulting", "Software", "Training", "Other"] }, { "name": "message", "label": "Your Message", "type": "textarea", "required": False, "placeholder": "Tell us how we can help..." } ], settings={ "title": "Contact Us", "description": "Get in touch with our sales team", "submitButtonText": "Send Message", "successMessage": "Thank you! We'll get back to you within 24 hours.", "redirectUrl": "https://example.com/thank-you", "notifyEmails": ["sales@company.com", "support@company.com"], "style": { "backgroundColor": "#ffffff", "buttonColor": "#007bff" } } ) print(f"Created form: {new_form['id']}") # Update a form updated_form = ghl.forms.update( form_id=new_form['id'], data={ "settings": { "title": "Contact Our Sales Team", "submitButtonText": "Submit Inquiry" } } ) print(f"Updated form: {updated_form['name']}") # Get form submissions submissions = ghl.forms.get_submissions( form_id="form_xyz789", limit=100, skip=0 ) for submission in submissions: print(f"Submission: {submission['id']} - {submission.get('email')}") # Get a specific submission submission = ghl.forms.get_submission( form_id="form_xyz789", submission_id="sub_abc123" ) print(f"Submission data: {submission}") # Delete a form deleted = ghl.forms.delete(form_id="form_old123") print(f"Form deleted: {deleted}") ``` -------------------------------- ### Manage GoHighLevel Opportunities (Python) Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Create, update, move to won, and delete opportunities within GoHighLevel. Requires the gohl library and authentication credentials. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Create a new opportunity new_opportunity = ghl.opportunities.create( location_id="loc_abc123", data={ "name": "Enterprise Software Deal", "description": "Large enterprise client interested in annual subscription", "value": 75000.00, "currency": "USD", "pipelineId": "pipe_sales", "stageId": "stage_qualified", "status": "open", "assignedTo": "user_123", "contactId": "contact_abc123", "priority": "high", "tags": ["enterprise", "q1-target", "software"], "customFields": { "industry": "Technology", "deal_source": "Referral", "contract_length": "12 months" }, "dueDate": "2024-03-31T23:59:59Z" } ) print(f"Created opportunity: {new_opportunity['id']}") # Update an opportunity updated_opportunity = ghl.opportunities.update( opportunity_id=new_opportunity['id'], data={ "value": 85000.00, "stageId": "stage_proposal", "priority": "high", "customFields": { "last_activity": "Proposal sent" } } ) print(f"Updated opportunity value: ${updated_opportunity['value']}") # Move opportunity to won won_deal = ghl.opportunities.update( opportunity_id=new_opportunity['id'], data={ "status": "won", "stageId": "stage_closed_won" } ) print(f"Deal won! Value: ${won_deal['value']}") # Delete an opportunity deleted = ghl.opportunities.delete(opportunity_id="opp_old123") print(f"Opportunity deleted: {deleted}") ``` -------------------------------- ### Media Library API Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Manage media files and folders within the GoHighLevel media library. ```APIDOC ## GET /medialibrary/files ### Description Retrieves a list of media files from the media library. ### Method GET ### Endpoint /medialibrary/files ### Parameters #### Path Parameters None #### Query Parameters - **location_id** (string) - Required - The ID of the location. - **folder_id** (string) - Optional - The ID of the folder to filter files by. - **limit** (integer) - Optional - The maximum number of files to return (default 50). - **skip** (integer) - Optional - The number of files to skip (default 0). #### Request Body None ### Request Example ``` GET /medialibrary/files?location_id=loc_abc123&folder_id=folder_images&limit=50&skip=0 ``` ### Response #### Success Response (200) - An array of file objects. - **id** (string) - The ID of the file. - **name** (string) - The name of the file. - **type** (string) - The type of the file (e.g., 'image', 'video'). - **url** (string) - The URL of the file. #### Response Example ```json [ { "id": "file_xyz789", "name": "product_image.jpg", "type": "image", "url": "https://example.com/path/to/product_image.jpg" } ] ``` --- ## GET /medialibrary/files/{file_id} ### Description Retrieves details for a specific media file. ### Method GET ### Endpoint /medialibrary/files/{file_id} ### Parameters #### Path Parameters - **file_id** (string) - Required - The ID of the file to retrieve. #### Query Parameters None #### Request Body None ### Request Example ``` GET /medialibrary/files/file_xyz789 ``` ### Response #### Success Response (200) - An object representing the file details. - **id** (string) - The ID of the file. - **name** (string) - The name of the file. - **url** (string) - The URL of the file. - **type** (string) - The type of the file. - **metadata** (object) - Metadata associated with the file. #### Response Example ```json { "id": "file_xyz789", "name": "product_image.jpg", "url": "https://example.com/path/to/product_image.jpg", "type": "image", "metadata": { "description": "Main product image", "tags": ["product", "featured"] } } ``` --- ## POST /medialibrary/files ### Description Uploads a new file to the media library. ### Method POST ### Endpoint /medialibrary/files ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **location_id** (string) - Required - The ID of the location to upload the file to. - **file** (file) - Required - The file to upload (multipart/form-data). - **metadata** (object) - Optional - Metadata for the file. - **name** (string) - Optional - The name of the file. - **description** (string) - Optional - A description for the file. - **folderId** (string) - Optional - The ID of the folder to place the file in. - **type** (string) - Optional - The type of the file. - **tags** (array) - Optional - An array of tags for the file. - **metadata** (object) - Optional - Additional custom metadata. ### Request Example ``` POST /medialibrary/files Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="location_id" loc_abc123 ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="product_image.jpg" Content-Type: image/jpeg [binary file content] ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="metadata" Content-Type: application/json { "name": "Product Hero Image", "folderId": "folder_products", "tags": ["product", "hero"] } ------WebKitFormBoundary7MA4YWxkTrZu0gW-- ``` ### Response #### Success Response (200) - **id** (string) - The ID of the uploaded file. - **name** (string) - The name of the uploaded file. - **url** (string) - The URL of the uploaded file. #### Response Example ```json { "id": "file_new123", "name": "Product Hero Image", "url": "https://example.com/path/to/product_image.jpg" } ``` --- ## PUT /medialibrary/files/{file_id} ### Description Updates the metadata of an existing media file. ### Method PUT ### Endpoint /medialibrary/files/{file_id} ### Parameters #### Path Parameters - **file_id** (string) - Required - The ID of the file to update. #### Query Parameters None #### Request Body - **data** (object) - Required - An object containing the metadata fields to update. - **name** (string) - Optional - The new name of the file. - **description** (string) - Optional - The new description for the file. - **tags** (array) - Optional - An array of new tags for the file. ### Request Example ```json { "data": { "name": "Updated Product Image", "description": "Updated description", "tags": ["product", "updated", "2024"] } } ``` ### Response #### Success Response (200) - **id** (string) - The ID of the updated file. - **name** (string) - The updated name of the file. #### Response Example ```json { "id": "file_xyz789", "name": "Updated Product Image" } ``` --- ## DELETE /medialibrary/files/{file_id} ### Description Deletes a media file from the media library. ### Method DELETE ### Endpoint /medialibrary/files/{file_id} ### Parameters #### Path Parameters - **file_id** (string) - Required - The ID of the file to delete. #### Query Parameters None #### Request Body None ### Request Example ``` DELETE /medialibrary/files/file_old123 ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the deletion was successful. #### Response Example ```json { "success": true } ``` --- ## GET /medialibrary/folders ### Description Retrieves a list of folders from the media library. ### Method GET ### Endpoint /medialibrary/folders ### Parameters #### Path Parameters None #### Query Parameters - **location_id** (string) - Required - The ID of the location. - **parent_id** (string) - Optional - The ID of the parent folder to list subfolders of (use null for root folders). - **limit** (integer) - Optional - The maximum number of folders to return (default 50). - **skip** (integer) - Optional - The number of folders to skip (default 0). #### Request Body None ### Request Example ``` GET /medialibrary/folders?location_id=loc_abc123&parent_id=null&limit=50&skip=0 ``` ### Response #### Success Response (200) - An array of folder objects. - **id** (string) - The ID of the folder. - **name** (string) - The name of the folder. #### Response Example ```json [ { "id": "folder_images", "name": "Images" } ] ``` --- ## POST /medialibrary/folders ### Description Creates a new folder in the media library. ### Method POST ### Endpoint /medialibrary/folders ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **location_id** (string) - Required - The ID of the location to create the folder in. - **folder** (object) - Required - An object containing the folder details. - **name** (string) - Required - The name of the folder. - **description** (string) - Optional - A description for the folder. - **parentId** (string) - Optional - The ID of the parent folder. - **permissions** (object) - Optional - Permissions for the folder. ### Request Example ```json { "location_id": "loc_abc123", "folder": { "name": "Marketing Assets 2024", "description": "All marketing materials for 2024 campaigns", "parentId": "folder_marketing" } } ``` ### Response #### Success Response (200) - **id** (string) - The ID of the newly created folder. - **name** (string) - The name of the created folder. #### Response Example ```json { "id": "folder_new456", "name": "Marketing Assets 2024" } ``` ``` -------------------------------- ### Manage Contacts and Tasks Source: https://github.com/m2kdevelopments/gohighlevel-py/blob/main/README.md Demonstrates how to interact with the Contacts API, including searching for contacts, retrieving all contacts within a location, creating new contacts, and adding tasks associated with contacts. ```python # Search contacts searched_contacts = ghl.contacts.search(query="martin") # Get all contacts contacts = ghl.contacts.get_all(location_id="your_location_id") # Create a new contact new_contact = ghl.contacts.add({ "firstName": "John", "lastName": "Doe", "email": "john.doe@example.com", "phone": "+1234567890", "locationId": "your_location_id" }) # Add a task for a contact task = ghl.contacts.tasks.add( contact_id="contact_id", title="Follow up", due_date="2024-01-15T10:00:00Z" ) ``` -------------------------------- ### Manage Sales Opportunities using GoHighLevel Python SDK Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Provides functionality to retrieve sales opportunities using the GoHighLevel Python SDK. Supports fetching all opportunities with filters or a single opportunity by ID. Requires credentials, location ID, and pipeline ID. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Get all opportunities opportunities = ghl.opportunities.get_all( location_id="loc_abc123", pipeline_id="pipe_sales", status="open", limit=50, skip=0 ) print(f"Found {len(opportunities)} open opportunities") # Get a single opportunity opportunity = ghl.opportunities.get(opportunity_id="opp_xyz789") print(f"Opportunity: {opportunity['name']} - Value: ${opportunity['value']}") ``` -------------------------------- ### Manage Calendar Resources - Python Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Facilitates the management of calendar resources such as rooms and equipment. Allows fetching existing resources by type and creating new ones with details like name, capacity, and amenities. Returns created resource information. ```python from gohl import GoHighLevel from gohl.classes.auth.credentials import Credentials credentials = Credentials(api_key="your_api_key") ghl = GoHighLevel(credentials=credentials) # Get all rooms rooms = ghl.calendar.resources.get_all(resource_type="rooms") for room in rooms: print(f"Room: {room['name']} - Capacity: {room.get('capacity')}") # Create a new room resource new_room = ghl.calendar.resources.add( resource_type="rooms", resource={ "name": "Conference Room A", "capacity": 20, "locationId": "loc_abc123", "description": "Large conference room with video conferencing", "amenities": ["projector", "whiteboard", "video_conferencing"] } ) print(f"Created room: {new_room}") ``` -------------------------------- ### Opportunities API Source: https://context7.com/m2kdevelopments/gohighlevel-py/llms.txt Manages sales opportunities, including retrieving and filtering them. ```APIDOC ## Opportunities API ### Manage Sales Opportunities Create, update, and track sales opportunities within the GoHighLevel platform. ### Method GET, POST, PUT, DELETE ### Endpoint - `/opportunities` (GET) - `/opportunities/{opportunity_id}` (GET) - `/opportunities` (POST) - `/opportunities/{opportunity_id}` (PUT) ### Parameters #### Path Parameters - **opportunity_id** (string) - Required - The ID of the opportunity. #### Query Parameters - **location_id** (string) - Required - The ID of the location. - **pipeline_id** (string) - Optional - The ID of the pipeline to filter opportunities by. - **status** (string) - Optional - The status of the opportunities to retrieve (e.g., 'open', 'closed'). - **limit** (integer) - Optional - The maximum number of opportunities to return. - **skip** (integer) - Optional - The number of opportunities to skip. #### Request Body (for POST and PUT) - **name** (string) - Required - The name of the opportunity. - **value** (number) - Required - The monetary value of the opportunity. - **pipeline_id** (string) - Required - The ID of the pipeline the opportunity belongs to. - **stage_id** (string) - Required - The ID of the current stage in the pipeline. - **contact_id** (string) - Required - The ID of the contact associated with the opportunity. - **custom_field** (object) - Optional - Key-value pairs for custom fields. ### Request Example (Get all opportunities) ```python opportunities = ghl.opportunities.get_all( location_id="loc_abc123", pipeline_id="pipe_sales", status="open", limit=50, skip=0 ) print(f"Found {len(opportunities)} open opportunities") ``` ### Request Example (Get a single opportunity) ```python opportunity = ghl.opportunities.get(opportunity_id="opp_xyz789") print(f"Opportunity: {opportunity['name']} - Value: ${opportunity['value']}") ``` ### Response #### Success Response (200) - **id** (string) - The opportunity ID. - **name** (string) - The name of the opportunity. - **value** (number) - The monetary value of the opportunity. - **pipelineId** (string) - The ID of the pipeline. - **stageId** (string) - The ID of the current stage. - **contactId** (string) - The ID of the associated contact. - **createdAt** (integer) - Timestamp of creation. - **updatedAt** (integer) - Timestamp of last update. #### Response Example (Get opportunity) ```json { "id": "opp_xyz789", "name": "Q1 Sales Deal", "value": 5000, "pipelineId": "pipe_sales", "stageId": "stage_prospecting", "contactId": "contact_abc123", "createdAt": 1678886400, "updatedAt": 1678886400 } ``` ```