AlterLabAlterLab
PricingComparePlaygroundBlogDocs
    AlterLabAlterLab
    PricingPlaygroundBlogDocsChangelog
    IntroductionInstallationYour First Request
    REST APIJob PollingAPI KeysSessions APINew
    OverviewPythonNode.js
    JavaScript RenderingOutput FormatsPDF & OCRCachingWebhooksJSON Schema FilteringWebSocket Real-TimeBring Your Own ProxyProAuthenticated ScrapingNewWeb CrawlingBatch ScrapingSchedulerChange DetectionCloud Storage ExportSpend LimitsOrganizations & TeamsAlerts & Notifications
    Structured ExtractionAIE-commerce ScrapingNews MonitoringPrice MonitoringMulti-Page CrawlingMonitoring DashboardAI Agent / MCPMCPData Pipeline to CloudAuthenticated AmazonNew
    PricingRate LimitsError Codes
    From FirecrawlFrom ApifyFrom ScrapingBee / ScraperAPI
    PlaygroundPricingStatus
    API Reference
    New

    Sessions API

    Manage stored browser sessions for authenticated web scraping. Create, validate, refresh, and monitor session health across all your target domains.

    Base URL

    https://api.alterlab.io/api/v1/sessions

    Cookie Security

    Cookie values are encrypted at rest with AES-256-GCM and are never returned in API responses. Responses include cookie names only, for debugging purposes. See the security section for details.

    Authentication

    All session endpoints require authentication via API key or JWT bearer token. Sessions are scoped to the authenticated user.

    Bash
    # API Key
    X-API-Key: sk_live_...
    
    # Or JWT Bearer Token
    Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

    Create Session

    POST
    /api/v1/sessions

    Create a new session integration with encrypted cookie storage.

    Parameters

    NameTypeRequiredDescription
    namestring
    Required
    Human-readable label for this session (e.g. "My Amazon Prime").
    domainstring
    Required
    Target domain (e.g. amazon.com). Protocols and paths are stripped automatically.
    cookiesobject
    Required
    Key-value map of cookie names to values. Values are encrypted before storage.
    headersobjectOptionalOptional custom headers to send with authenticated requests.
    expires_atstringOptionalOptional ISO-8601 expiration timestamp. AlterLab marks the session as expired after this time.
    notesstringOptionalOptional user notes (max 1000 characters).

    Request Example

    Bash
    {
      "name": "My Amazon Prime",
      "domain": "amazon.com",
      "cookies": {
        "session-id": "144-1234567-8901234",
        "session-token": "abc123xyz789..."
      },
      "headers": {
        "Accept-Language": "en-US,en;q=0.9"
      },
      "expires_at": "2026-04-01T00:00:00Z",
      "notes": "Primary US account"
    }

    Response Example

    JSON
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "My Amazon Prime",
      "domain": "amazon.com",
      "cookie_names": ["session-id", "session-token"],
      "header_names": ["Accept-Language"],
      "status": "active",
      "expires_at": "2026-04-01T00:00:00Z",
      "last_validated_at": null,
      "validation_confidence": null,
      "consecutive_failures": 0,
      "last_used_at": null,
      "total_requests": 0,
      "successful_requests": 0,
      "success_rate": 0,
      "notes": "Primary US account",
      "created_at": "2026-03-18T12:00:00Z",
      "updated_at": "2026-03-18T12:00:00Z"
    }
    Python
    from alterlab import AlterLabSync
    
    client = AlterLabSync(api_key="YOUR_API_KEY")
    
    session = client.sessions.create(
        name="My Amazon Prime",
        domain="amazon.com",
        cookies={
            "session-id": "144-1234567-8901234",
            "session-token": "abc123xyz789...",
        },
        expires_at="2026-04-01T00:00:00Z",
        notes="Primary US account",
    )
    print(session["id"])

    List Sessions

    GET
    /api/v1/sessions

    List all session integrations for the authenticated user. Supports filtering by domain and status.

    Parameters

    NameTypeRequiredDescription
    domainstringOptionalFilter sessions by domain (e.g. amazon.com).
    statusstringOptionalFilter by status: active, expired, invalid, or pending_validation.

    Response Example

    JSON
    {
      "sessions": [
        {
          "id": "a1b2c3d4-...",
          "name": "My Amazon Prime",
          "domain": "amazon.com",
          "cookie_names": ["session-id", "session-token"],
          "status": "active",
          "consecutive_failures": 0,
          "total_requests": 47,
          "successful_requests": 45,
          "success_rate": 95.7,
          "created_at": "2026-03-18T12:00:00Z",
          "updated_at": "2026-03-18T14:30:00Z"
        }
      ],
      "total": 1
    }
    Python
    # List all sessions
    result = client.sessions.list()
    for s in result["sessions"]:
        print(f"{s['name']} ({s['domain']}) — {s['status']}")
    
    # Filter by domain
    amazon_sessions = client.sessions.list(domain="amazon.com")
    
    # Filter by status
    expired = client.sessions.list(status="expired")

    Get Session

    GET
    /api/v1/sessions/{session_id}

    Get details for a single session integration. Returns all metadata including health stats.

    Parameters

    NameTypeRequiredDescription
    session_iduuid
    Required
    UUID of the session to retrieve.

    Response Example

    JSON
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "My Amazon Prime",
      "domain": "amazon.com",
      "cookie_names": ["session-id", "session-token"],
      "header_names": ["Accept-Language"],
      "status": "active",
      "expires_at": "2026-04-01T00:00:00Z",
      "last_validated_at": "2026-03-18T14:00:00Z",
      "validation_confidence": 92,
      "consecutive_failures": 0,
      "last_used_at": "2026-03-18T14:30:00Z",
      "total_requests": 47,
      "successful_requests": 45,
      "success_rate": 95.7,
      "notes": "Primary US account",
      "created_at": "2026-03-18T12:00:00Z",
      "updated_at": "2026-03-18T14:30:00Z"
    }

    Update Session

    PATCH
    /api/v1/sessions/{session_id}

    Update a session integration. Only provided fields are changed. Use refresh for cookie-only rotation with automatic re-validation.

    Parameters

    NameTypeRequiredDescription
    session_iduuid
    Required
    UUID of the session to update.
    namestringOptionalNew session label.
    cookiesobjectOptionalNew cookie name-value mapping. Replaces all cookies.
    headersobjectOptionalNew custom headers. Replaces all headers.
    expires_atstringOptionalNew expiration timestamp (ISO-8601).
    notesstringOptionalNew notes.

    Request Example

    Bash
    {
      "name": "Amazon Prime (Refreshed)",
      "expires_at": "2026-05-01T00:00:00Z"
    }

    Response Example

    JSON
    {
      "id": "a1b2c3d4-...",
      "name": "Amazon Prime (Refreshed)",
      "domain": "amazon.com",
      "status": "active",
      "expires_at": "2026-05-01T00:00:00Z",
      ...
    }

    Delete Session

    DELETE
    /api/v1/sessions/{session_id}

    Soft-delete a session integration. The session is marked as inactive but the audit trail is preserved. Returns 204 No Content on success.

    Parameters

    NameTypeRequiredDescription
    session_iduuid
    Required
    UUID of the session to delete.
    Python
    client.sessions.delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890")

    Validate Session

    POST
    /api/v1/sessions/{session_id}/validate

    Validate a session by making a real HTTP request to the target domain using the stored cookies. Checks for logged-in indicators and returns a confidence score.

    Parameters

    NameTypeRequiredDescription
    session_iduuid
    Required
    UUID of the session to validate.

    Response Example

    JSON
    {
      "is_valid": true,
      "confidence": 92,
      "http_status": 200,
      "detected_user": "[email protected]",
      "cookie_expiry_detected": "2026-04-01T00:00:00Z",
      "cookies_expiring_soon": false,
      "indicators_found": {
        "account_links": ["/account", "/orders"],
        "user_elements": ["Hello, John"]
      },
      "consecutive_failures": 0,
      "details": "Session is valid. Detected logged-in user via account menu."
    }

    Validation Makes Real Requests

    Validation sends a real HTTP request to the target domain. This counts as a scrape and uses credits. Use it after creating or refreshing a session, not on every scrape request.
    Python
    validation = client.sessions.validate("a1b2c3d4-...")
    if validation["is_valid"]:
        print(f"Session valid (confidence: {validation['confidence']}%)")
        if validation.get("detected_user"):
            print(f"Logged in as: {validation['detected_user']}")
    else:
        print(f"Session invalid: {validation['details']}")

    Refresh Session

    POST
    /api/v1/sessions/{session_id}/refresh

    Replace all cookies in a session with fresh ones. Resets consecutive failure counters and sets status back to active. Use this when cookies expire.

    Parameters

    NameTypeRequiredDescription
    session_iduuid
    Required
    UUID of the session to refresh.
    cookiesobject
    Required
    New cookie name-value mapping. Replaces all existing cookies.
    headersobjectOptionalOptional new custom headers.

    Request Example

    Bash
    {
      "cookies": {
        "session-id": "new-144-7654321-0987654",
        "session-token": "new-xyz789abc123..."
      }
    }

    Response Example

    JSON
    {
      "id": "a1b2c3d4-...",
      "name": "My Amazon Prime",
      "domain": "amazon.com",
      "cookie_names": ["session-id", "session-token"],
      "status": "active",
      "consecutive_failures": 0,
      ...
    }
    Python
    # Refresh with new cookies
    updated = client.sessions.refresh(
        "a1b2c3d4-...",
        cookies={
            "session-id": "new-144-7654321-0987654",
            "session-token": "new-xyz789abc123...",
        },
    )
    print(f"Status: {updated['status']}")  # "active"

    Share with Organization

    PATCH
    /api/v1/sessions/{session_id}/share

    Share a session with your organization. Requires org admin role. Shared sessions are read-only for non-admin org members — they can use them for scraping but cannot modify or delete them.

    Parameters

    NameTypeRequiredDescription
    session_iduuid
    Required
    UUID of the session to share.
    organization_iduuid
    Required
    UUID of the organization to share with.

    Request Example

    Bash
    {
      "organization_id": "org-uuid-1234-..."
    }

    Unshare Session

    PATCH
    /api/v1/sessions/{session_id}/unshare

    Remove organization sharing from a session. Requires org admin role.

    Parameters

    NameTypeRequiredDescription
    session_iduuid
    Required
    UUID of the session to unshare.

    Audit Log

    GET
    /api/v1/sessions/{session_id}/audit

    Retrieve the audit log for a session. Shows all operations performed on the session with timestamps and actor identity.

    Parameters

    NameTypeRequiredDescription
    session_iduuid
    Required
    UUID of the session.

    Response Example

    JSON
    {
      "entries": [
        {
          "action": "created",
          "actor": "[email protected]",
          "timestamp": "2026-03-18T12:00:00Z",
          "details": {}
        },
        {
          "action": "validated",
          "actor": "[email protected]",
          "timestamp": "2026-03-18T14:00:00Z",
          "details": { "is_valid": true, "confidence": 92 }
        },
        {
          "action": "used_for_scrape",
          "actor": "system",
          "timestamp": "2026-03-18T14:30:00Z",
          "details": { "url": "https://www.amazon.com/dp/B0EXAMPLE" }
        }
      ],
      "total": 3
    }

    Scraping with a Session

    To use a stored session for scraping, pass the session_id parameter in your scrape request. Alternatively, pass cookies directly for one-off requests.

    POST
    /api/v1/scrape

    Scrape a URL with authenticated session cookies. The session_id and cookies parameters are mutually exclusive.

    Parameters

    NameTypeRequiredDescription
    urlstring
    Required
    URL to scrape.
    session_iduuidOptionalUUID of a stored session. Domain must match the URL. Mutually exclusive with cookies.
    cookiesobjectOptionalInline cookie key-value map for one-off use. Not stored. Mutually exclusive with session_id.

    Request Example

    Bash
    {
      "url": "https://www.amazon.com/dp/B0EXAMPLE",
      "session_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
    }

    Response Example

    JSON
    {
      "url": "https://www.amazon.com/dp/B0EXAMPLE",
      "status_code": 200,
      "content": "<!DOCTYPE html>...",
      "title": "Product Name — Amazon.com",
      "byos_applied": true,
      "billing": {
        "total_credits": 1,
        "tier_used": "1"
      }
    }

    The response includes "byos_applied": true when session cookies were injected into the request. If the session is expired or invalid, the scrape proceeds without authentication and byos_applied will be false.

    Session Object Schema

    FieldTypeDescription
    iduuidUnique identifier for the session.
    namestringUser-defined label for the session.
    domainstringTarget domain. Cookies are only sent to URLs matching this domain.
    cookie_namesstring[]Names of stored cookies (values are never exposed).
    header_namesstring[] | nullNames of custom headers, if any.
    statusenumOne of: active, expired, invalid, pending_validation.
    expires_atstring | nullISO-8601 expiration timestamp, if set.
    last_validated_atstring | nullTimestamp of the last validation check.
    validation_confidencenumber | nullConfidence score (0-100) from the last validation.
    consecutive_failuresnumberNumber of consecutive failed scrapes with this session.
    last_used_atstring | nullTimestamp of the last scrape using this session.
    total_requestsnumberTotal scrape requests made with this session.
    successful_requestsnumberNumber of successful (authenticated) scrapes.
    success_ratenumberSuccess percentage (0-100).
    notesstring | nullUser notes (max 1000 chars).
    created_atstringISO-8601 creation timestamp.
    updated_atstringISO-8601 last update timestamp.

    Error Codes

    CodeHTTPDescriptionResolution
    SESSION_NOT_FOUND404The session_id does not exist or belongs to another user.Verify the UUID. Use GET /sessions to list valid sessions.
    SESSION_EXPIRED410Session cookies have expired or the session was marked expired.Log in again and POST /sessions/:id/refresh with fresh cookies.
    SESSION_DOMAIN_MISMATCH400The scrape URL domain does not match the session domain.Create a separate session for the target domain.
    SESSION_INACTIVE410Session has been deleted or disabled.Create a new session.
    SESSION_LIMIT_REACHED429Maximum of 50 sessions per account reached.Delete unused sessions to free up slots.
    SESSION_COOKIES_CONFLICT400Both session_id and cookies were provided in the scrape request.Use one or the other, not both.

    See the full Error Codes Reference for all API error codes.

    Rate Limits

    EndpointLimitWindow
    POST /sessions10 requestsper minute
    POST /sessions/:id/validate5 requestsper minute
    POST /sessions/:id/refresh10 requestsper minute
    GET /sessions (list)30 requestsper minute
    Other endpoints30 requestsper minute
    ← REST API ReferenceAuthenticated Scraping Guide →
    Last updated: March 2026

    On this page

    AlterLabAlterLab

    AlterLab is the modern web scraping platform for developers. Reliable, scalable, and easy to use.

    Product

    • Pricing
    • Documentation
    • Changelog
    • Status

    Solutions

    • Python API
    • JS Rendering
    • Anti-Bot Bypass
    • Compare APIs

    Comparisons

    • Compare All
    • vs ScraperAPI
    • vs Firecrawl
    • vs ScrapingBee
    • vs Bright Data
    • vs Apify

    Company

    • About
    • Blog
    • Contact
    • FAQ

    Guides

    • Bypass Cloudflare
    • Playwright Anti-Detection
    • Puppeteer Bypass Guide
    • Selenium Detection Fix
    • Best Scraping APIs 2026

    Legal

    • Privacy
    • Terms
    • Acceptable Use
    • DPA
    • Cookie Policy
    • Licenses

    © 2026 RapierCraft Inc. All rights reserved.

    Middletown, DE