API Reference / Stop a live session
API Reference

Stop a live session

DELETE/api/v1/live/sessions/{id}

Stops the session. The session keeps what its frames cost; the rest of the credits it held go back to your balance. Stopping a session that has already stopped returns it unchanged.

Path parameters#

Parameter Type Description
id required integer Session id.

Responses#

200#

The stopped session.

  • id integer required

    Session id.

  • source string required

    One of: url, camera. url (a stream watched by our servers) or camera (frames you send).

  • url string or null required

    The stream address; null for camera sessions.

  • fps number required

    Frames checked per second.

  • mode string required

    One of: detect, capture, censor. detect, capture or censor.

  • censorStyle string or null required

    One of: blur, pixelate, box, null. How the moments' censored copies hide what was found; null unless mode is censor.

  • tracking boolean required

    Whether findings are followed from frame to frame (see tracking when starting).

  • frameSide integer required

    Long side, in pixels, of the pictures kept.

  • momentEvery integer required

    Seconds at least between two kept moments.

  • status string required

    One of: running, stopped, ended, failed. stopped: by you or when the credits ran out. ended: the stream ended. failed: the stream could not be watched.

  • reason string or null required

    Why the session is no longer running.

  • framesChecked integer required

    Frames checked so far.

  • framesFlagged integer required

    Frames that raised at least one flag.

  • moments integer required

    Flagged frames kept, with their picture, in your moderation history.

  • creditsCharged integer required

    Credits taken from your balance for the session. While it runs this includes the minute held ahead; when it ends, what its frames did not use goes back and this is what the session cost.

  • creditsUsed integer required

    What the frames checked so far cost: each frame costs costPerMinute / (60 x fps), rounded up to whole credits for the session, and never more than creditsCharged. Equal to creditsCharged once the session has ended.

  • costPerMinute integer required

    What a minute at the session's rate costs: the credits held ahead each minute.

  • startedAt integer required

    Unix time, seconds.

  • endedAt integer or number or null required

    Unix time, seconds; null while running.

  • jobId integer or null required

    The session's entry in your moderation history.

  • width integer

    Stream sessions while running: the stream's width.

  • height integer

    Stream sessions while running: the stream's height.

  • flags array or null required

    The flags checked on every frame, as chosen at the start; null: every flag.

  • metadata object

    The session's metadata, unchanged, when you sent one.

401#

Missing, unknown, revoked or expired API key, or the account is not active.

{
  "error": "unauthorized",
  "message": "The API key is not valid."
}

403#

The key may not do this: a read key on a write endpoint, or a restricted key.

{
  "error": "forbidden",
  "message": "This API key does not have write permission"
}

404#

No session with this id for this account.

{
  "error": "not_found",
  "message": "No such live session."
}

429#

Too many requests in a minute. Wait Retry-After seconds. See Rate limits.

Header Retry-After: Seconds to wait.

{
  "error": "too_many_requests",
  "message": "Too many requests. Try again in a minute."
}

Request

curl -X DELETE https://api.detectivision.ai/api/v1/live/sessions/{id} \
  -H "Api-Key: $DETECTIVISION_API_KEY"
import os, requests

r = requests.delete(
    "https://api.detectivision.ai/api/v1/live/sessions/{id}",
    headers={"Api-Key": os.environ["DETECTIVISION_API_KEY"]},
)
print(r.status_code, r.json())
const res = await fetch("https://api.detectivision.ai/api/v1/live/sessions/{id}", {
  method: "DELETE",
  headers: {
    "Api-Key": process.env.DETECTIVISION_API_KEY,
  },
});
console.log(res.status, await res.json());

Response 200

{
  "id": 31,
  "source": "url",
  "url": "rtsp://cams.example.com/live",
  "fps": 1,
  "mode": "capture",
  "censorStyle": null,
  "tracking": false,
  "frameSide": 1280,
  "momentEvery": 3,
  "status": "stopped",
  "reason": "Stopped by the owner.",
  "framesChecked": 94,
  "framesFlagged": 3,
  "moments": 2,
  "creditsCharged": 4,
  "creditsUsed": 4,
  "costPerMinute": 2,
  "startedAt": 1790505000,
  "endedAt": 1790505095,
  "jobId": 2210
}