---
title: "Creates a context for live sampling"
method: GET
path: "/pmapi/context"
tags: ["PMAPI HOST SERVICES"]
---

# Creates a context for live sampling

`GET /pmapi/context`

To create a context for live sampling, a web client can access any */pmapi* URL (optionally using the *hostspec* or *context* parameter). If no 
context exists, a new one will be created for that web client, and its identifier returned for future accesses.

However, */pmapi/context* is provided as a dedicated URL for applications wishing to explicitly create the contexts they use.
```
$ curl -s http://localhost:44322/pmapi/context?hostspec=www.acme.com&polltimeout=0.5 | pmjson
```
The context (a 32-bit unsigned decimal number) can then be used with all later requests.

In the case of a *hostspec* containing authentication information, such as a username, the server will follow the HTTP Basic Authentication 
protocol to ascertain necessary authentication details from the user, providing the client web application an opportunity to request these from 
the user.

**Reference:** [pmNewContext](https://man7.org/linux/man-pages/man3/pmNewContext.3.html)(3)

## Query parameters

- `hostspec` string
- `polltimeout` number
- `client` string

## Response `200`

OK

## Changes

- **2020-10-21** `26cabf98ddfb` — 1 info
  - endpoint added
- **2020-10-20** `7da0633fad91` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/performancecopilot/apis/pmwebapi/changes/pmapi/context/get.md)

---

[API](https://skmtc.dev/performancecopilot/apis/pmwebapi.md) · [All operations](https://skmtc.dev/performancecopilot/apis/pmwebapi/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/performancecopilot/pmwebapi/revisions/666212c8ed6b/schema)
