# Provisioning State

## Get provisioning state information

> Gets the provisioning state information (DEPRECATED: Use GET /api/v1/state/connections instead)

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_ProvisioningState"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_ViewStateAPIResponse":{"required":["connections"],"type":"object","properties":{"connections":{"$ref":"#/components/schemas/agent_Map_String_List_ConnectionStateResponse"}}},"agent_Map_String_List_ConnectionStateResponse":{"type":"object","additionalProperties":{"type":"array","items":{"$ref":"#/components/schemas/agent_ConnectionStateResponse"}}},"agent_ConnectionStateResponse":{"required":["name","version"],"type":"object","properties":{"name":{"type":"string"},"version":{"type":"integer"},"tags":{"type":"array","items":{"type":"string"}}}},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/state":{"get":{"tags":["agent_ProvisioningState"],"summary":"Get provisioning state information","description":"Gets the provisioning state information (DEPRECATED: Use GET /api/v1/state/connections instead)","operationId":"viewProvisioningState","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_ViewStateAPIResponse"}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Get raw provisioning file contents

> Gets the raw provisioning.yaml file contents

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_ProvisioningState"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/state/connections":{"get":{"tags":["agent_ProvisioningState"],"summary":"Get raw provisioning file contents","description":"Gets the raw provisioning.yaml file contents","operationId":"getProvisionedConnections","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"text/plain":{"schema":{"type":"string"}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Upload complete provisioning manifest with files

> Uploads a complete provisioning manifest as YAML along with referenced files to the configured scanner folder. This replaces the entire connection state - any existing connections not in the manifest will be deleted. If no 'lensesHq' section is provided in the manifest, the existing HQ connection will be automatically preserved.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_ProvisioningState"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_ProvisioningValidationResponse":{"required":["valid","message"],"type":"object","properties":{"valid":{"type":"boolean"},"message":{"type":"string"},"connections":{"type":"array","items":{"$ref":"#/components/schemas/agent_ProvisioningValidationConnection"}},"summary":{"$ref":"#/components/schemas/agent_ProvisioningValidationSummary"}}},"agent_ProvisioningValidationConnection":{"required":["name","valid","error"],"type":"object","properties":{"name":{"type":"string"},"valid":{"type":"boolean"},"error":{"type":"string"},"lineNumbers":{"type":"array","items":{"type":"integer"}},"fieldPaths":{"type":"array","items":{"type":"string"}}}},"agent_ProvisioningValidationSummary":{"type":"object","properties":{"created":{"type":"array","items":{"type":"string"}},"updated":{"type":"array","items":{"type":"string"}},"deleted":{"type":"array","items":{"type":"string"}}}},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Conflict":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/state/connections/upload":{"post":{"tags":["agent_ProvisioningState"],"summary":"Upload complete provisioning manifest with files","description":"Uploads a complete provisioning manifest as YAML along with referenced files to the configured scanner folder. This replaces the entire connection state - any existing connections not in the manifest will be deleted. If no 'lensesHq' section is provided in the manifest, the existing HQ connection will be automatically preserved.","operationId":"putProvisioningConnectionsWithFiles","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"multipart/form-data":{"schema":{"type":"string","format":"binary"}}},"required":true},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_ProvisioningValidationResponse"}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"409":{"description":"The supplied identifier is already being used by another resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Conflict"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Validate provisioning manifest with files

> Validates a provisioning manifest with uploaded files without applying changes. Uses full upload validation (replaces entire state).

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_ProvisioningState"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_ProvisioningValidationResponse":{"required":["valid","message"],"type":"object","properties":{"valid":{"type":"boolean"},"message":{"type":"string"},"connections":{"type":"array","items":{"$ref":"#/components/schemas/agent_ProvisioningValidationConnection"}},"summary":{"$ref":"#/components/schemas/agent_ProvisioningValidationSummary"}}},"agent_ProvisioningValidationConnection":{"required":["name","valid","error"],"type":"object","properties":{"name":{"type":"string"},"valid":{"type":"boolean"},"error":{"type":"string"},"lineNumbers":{"type":"array","items":{"type":"integer"}},"fieldPaths":{"type":"array","items":{"type":"string"}}}},"agent_ProvisioningValidationSummary":{"type":"object","properties":{"created":{"type":"array","items":{"type":"string"}},"updated":{"type":"array","items":{"type":"string"}},"deleted":{"type":"array","items":{"type":"string"}}}},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/state/connections/validate/upload":{"post":{"tags":["agent_ProvisioningState"],"summary":"Validate provisioning manifest with files","description":"Validates a provisioning manifest with uploaded files without applying changes. Uses full upload validation (replaces entire state).","operationId":"validateProvisioningConnectionsWithFiles","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"multipart/form-data":{"schema":{"type":"string","format":"binary"}}},"required":true},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_ProvisioningValidationResponse"}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```
