Lybic Docs

Extend Sandbox Lifetime

Each sandbox is created with an expiry time that you set. Once the time expires, the sandbox is deleted automatically. If you need more time, you can extend the sandbox lifetime as described below.

Note: Due to the certificate validity of the streaming client, cumulative extensions for a sandbox cannot exceed 13 days.

The extension duration is relative to the time of the operation and cannot exceed 24 hours per request or 13 days relative to the creation time.

Extending via the Console

In the Sandbox Management Console, open the sandbox details view to extend the lifetime manually:

  • Click the “Extend” button.
  • Enter the amount of time you’d like to add (up to 1 day per extension, with a 13-day total limit).
  • Click “Extend”.
Extend Sandbox

Extending via API

You can also extend sandbox lifetime programmatically through the API.

API Endpoint

POST /api/orgs/{orgId}/sandboxes/{sandboxId}/extend

Request Examples

curl -X POST "https://api.lybic.cn/api/orgs/{orgId}/sandboxes/{sandboxId}/extend" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{
    "maxLifeSeconds": 3600
  }'
import asyncio
from lybic import LybicClient, LybicAuth

async def main():
    async with LybicClient(
        LybicAuth(
            org_id="ORG-xxxx",
            api_key="lysk-xxxxxxxxxxx",
            endpoint="https://api.lybic.cn/"
        )
    ) as client:
        # extend the sandbox by 1 hour (3600 seconds)
        await client.sandbox.extend(
            sandbox_id="SBX-xxxx",
            max_life_seconds=3600
        )
        print("Sandbox extended successfully")

if __name__ == "__main__":
    asyncio.run(main())
import { LybicClient } from '@lybic/core'

const lybic = new LybicClient({
  baseUrl: 'https://api.lybic.cn',
  orgId: 'ORG-xxxx',
  apiKey: 'lysk-your-api-key-here',
})

// extend the sandbox by 1 hour (3600 seconds)
await lybic.client.POST('/api/orgs/{orgId}/sandboxes/{sandboxId}/extend', {
  params: {
    path: {
      orgId: lybic.orgId,
      sandboxId: 'SBX-xxxx',
    },
  },
  body: {
    maxLifeSeconds: 3600,
  },
})

console.log('Sandbox extended successfully')
package main

import (
    "context"
    "fmt"
    "github.com/lybic/lybic-sdk-go"
)

func main() {
    ctx := context.Background()
    client, _ := lybic.NewClient(nil)

    // extend the sandbox by 1 hour (3600 seconds)
    var maxLife float32 = 3600
    err := client.ExtendSandbox(ctx, "SBX-xxxx", lybic.ExtendSandboxDto{
        MaxLifeSeconds: &maxLife,
    })
    if err != nil {
        fmt.Printf("Error extending sandbox: %v\n", err)
        return
    }
    fmt.Println("Sandbox extended successfully")
}

Parameters

  • orgId: Organization ID (path parameter)
  • sandboxId: Sandbox ID (path parameter)
  • maxLifeSeconds: Extension time in seconds relative to the current time (request body)
    • Minimum: 30 seconds
    • Maximum: 86400 seconds (24 hours)
    • Default: 3600 seconds (1 hour)

Notes

  1. Extension limits: Each single extension must be between 30 seconds and 24 hours (86400 seconds).
  2. Total limit: The cumulative usage time for a sandbox cannot exceed 13 days due to the streaming client certificate.
  3. Relative time: maxLifeSeconds is relative to the current time, not an absolute timestamp.
  4. Authentication: Include a valid API token in the request headers.
  5. Permissions: Ensure the API token has permission to manage the organization and sandbox.

Sample: Extend by 2 Hours

curl -X POST "https://api.lybic.cn/api/orgs/my-org-id/sandboxes/my-sandbox-id/extend" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{
    "maxLifeSeconds": 7200
  }'
import asyncio
from lybic import LybicClient, LybicAuth

async def main():
    async with LybicClient(
        LybicAuth(
            org_id="my-org-id",
            api_key="lysk-xxxxxxxxxxx",
            endpoint="https://api.lybic.cn/"
        )
    ) as client:
        # extend the sandbox by 2 hours (7200 seconds)
        await client.sandbox.extend_life(
            sandbox_id="my-sandbox-id",
            seconds=7200
        )
        print("Sandbox extended by 2 hours successfully")

if __name__ == "__main__":
    asyncio.run(main())
import { LybicClient } from '@lybic/core'

const lybic = new LybicClient({
  baseUrl: 'https://api.lybic.cn',
  orgId: 'my-org-id',
  apiKey: 'lysk-your-api-key-here',
})

// extend the sandbox by 2 hours (7200 seconds)
await lybic.client.POST('/api/orgs/{orgId}/sandboxes/{sandboxId}/extend', {
  params: {
    path: {
      orgId: lybic.orgId,
      sandboxId: 'my-sandbox-id',
    },
  },
  body: {
    maxLifeSeconds: 7200,
  },
})

console.log('Sandbox extended by 2 hours successfully')
package main

import (
    "context"
    "fmt"
    "github.com/lybic/lybic-sdk-go"
)

func main() {
    ctx := context.Background()
    
    config := lybic.NewConfig()
    config.OrgId = "my-org-id"
    config.ApiKey = "your-api-key"
    
    client, _ := lybic.NewClient(config)

    // extend the sandbox by 2 hours (7200 seconds)
    var maxLife float32 = 7200
    err := client.ExtendSandbox(ctx, "my-sandbox-id", lybic.ExtendSandboxDto{
        MaxLifeSeconds: &maxLife,
    })
    if err != nil {
        fmt.Printf("Error extending sandbox: %v\n", err)
        return
    }
    fmt.Println("Sandbox extended by 2 hours successfully")
}

On this page