# State

## List global state keys

> Returns the list of all global state key names. Does \*\*not\*\* return\
> resource-scoped keys — use \`GET /v1/{resourceType}/{\_id}/state\` for\
> those.\
> \
> Returns \`204 No Content\` when no global keys exist.

```json
{"openapi":"3.1.0","info":{"title":"State","version":"1.0.0"},"servers":[{"url":"https://api.integrator.io","description":"Production (US / default region)"},{"url":"https://api.eu.integrator.io","description":"Production (EU region)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}},"responses":{"401-unauthorized":{"description":"Unauthorized. The request lacks a valid bearer token, or the provided token\nfailed to authenticate.\n\nNote: the 401 response is produced by the auth middleware **before** the\nrequest reaches the endpoint handler, so it does **not** follow the\nstandard `{errors: [...]}` envelope. Instead the body is a bare\n`{message: string}` object with no `code`, no `errors` array. Callers\nhandling 401s should key off the HTTP status and the `message` string,\nnot try to destructure an `errors[]`.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable description of the auth failure. Known values:\n- `\"Unauthorized\"` — no `Authorization` header on the request.\n- `\"Bearer Authentication Failed\"` — header present but token\n  is invalid, revoked, or expired."}},"required":["message"]}}}}}},"paths":{"/v1/state":{"get":{"operationId":"listGlobalStateKeys","tags":["State"],"summary":"List global state keys","description":"Returns the list of all global state key names. Does **not** return\nresource-scoped keys — use `GET /v1/{resourceType}/{_id}/state` for\nthose.\n\nReturns `204 No Content` when no global keys exist.","responses":{"200":{"description":"Object containing an array of key names.","content":{"application/json":{"schema":{"type":"object","required":["keys"],"properties":{"keys":{"type":"array","items":{"type":"string"}}}}}}},"204":{"description":"No global state keys exist."},"401":{"$ref":"#/components/responses/401-unauthorized"}}}}}}
```

## Delete all global state keys

> Deletes \*\*all\*\* global state keys and their values. This is a\
> destructive operation and cannot be undone.

```json
{"openapi":"3.1.0","info":{"title":"State","version":"1.0.0"},"servers":[{"url":"https://api.integrator.io","description":"Production (US / default region)"},{"url":"https://api.eu.integrator.io","description":"Production (EU region)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}},"responses":{"401-unauthorized":{"description":"Unauthorized. The request lacks a valid bearer token, or the provided token\nfailed to authenticate.\n\nNote: the 401 response is produced by the auth middleware **before** the\nrequest reaches the endpoint handler, so it does **not** follow the\nstandard `{errors: [...]}` envelope. Instead the body is a bare\n`{message: string}` object with no `code`, no `errors` array. Callers\nhandling 401s should key off the HTTP status and the `message` string,\nnot try to destructure an `errors[]`.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable description of the auth failure. Known values:\n- `\"Unauthorized\"` — no `Authorization` header on the request.\n- `\"Bearer Authentication Failed\"` — header present but token\n  is invalid, revoked, or expired."}},"required":["message"]}}}}}},"paths":{"/v1/state":{"delete":{"operationId":"deleteAllGlobalState","tags":["State"],"summary":"Delete all global state keys","description":"Deletes **all** global state keys and their values. This is a\ndestructive operation and cannot be undone.","responses":{"204":{"description":"All global state deleted."},"401":{"$ref":"#/components/responses/401-unauthorized"}}}}}}
```

## Get a global state value

> Returns the JSON value stored under the given global key.

```json
{"openapi":"3.1.0","info":{"title":"State","version":"1.0.0"},"servers":[{"url":"https://api.integrator.io","description":"Production (US / default region)"},{"url":"https://api.eu.integrator.io","description":"Production (EU region)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}},"responses":{"401-unauthorized":{"description":"Unauthorized. The request lacks a valid bearer token, or the provided token\nfailed to authenticate.\n\nNote: the 401 response is produced by the auth middleware **before** the\nrequest reaches the endpoint handler, so it does **not** follow the\nstandard `{errors: [...]}` envelope. Instead the body is a bare\n`{message: string}` object with no `code`, no `errors` array. Callers\nhandling 401s should key off the HTTP status and the `message` string,\nnot try to destructure an `errors[]`.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable description of the auth failure. Known values:\n- `\"Unauthorized\"` — no `Authorization` header on the request.\n- `\"Bearer Authentication Failed\"` — header present but token\n  is invalid, revoked, or expired."}},"required":["message"]}}}}}},"paths":{"/v1/state/{key}":{"get":{"operationId":"getGlobalStateValue","tags":["State"],"summary":"Get a global state value","description":"Returns the JSON value stored under the given global key.","parameters":[{"name":"key","in":"path","required":true,"schema":{"type":"string"},"description":"The state key name."}],"responses":{"200":{"description":"The stored value (a JSON object or array).","content":{"application/json":{"schema":{"oneOf":[{"title":"Object","type":"object"},{"title":"Array","type":"array"}]}}}},"401":{"$ref":"#/components/responses/401-unauthorized"},"404":{"description":"The key does not exist.","content":{"application/json":{"schema":{"type":"object","required":["errors"],"properties":{"errors":{"type":"array","items":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}}}}}}}
```

## Create or update a global state value

> Sets the value for a global state key. Creates the key if it does\
> not exist; replaces the value if it does.\
> \
> The request body must be a non-empty JSON object or array. Bare\
> JSON primitives (strings, numbers, booleans, \`null\`) and empty\
> containers (\`{}\`, \`\[]\`) are rejected.

```json
{"openapi":"3.1.0","info":{"title":"State","version":"1.0.0"},"servers":[{"url":"https://api.integrator.io","description":"Production (US / default region)"},{"url":"https://api.eu.integrator.io","description":"Production (EU region)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}},"schemas":{"Error":{"type":"object","description":"Standard error response envelope returned by integrator.io APIs.","properties":{"errors":{"type":"array","description":"List of errors that occurred while processing the request.","items":{"type":"object","properties":{"code":{"oneOf":[{"type":"string"},{"type":"integer"}],"description":"Machine-readable error code. Usually a string like\n`invalid_ref`, `missing_required_field`, or `unauthorized`;\nmay be an **integer** when the error mirrors an upstream HTTP\nstatus (e.g. `500`) — most commonly returned by connection-ping\nand adaptor-proxy responses."},"message":{"type":"string","description":"Human-readable description of the error."},"field":{"type":"string","description":"Optional pointer to the document field that caused the error.\nUsed by structural validation errors (`missing_required_field`,\n`invalid_ref`) to indicate which field is at fault\n(e.g. `_id`, `type`, `http.baseURI`)."},"source":{"type":"string","description":"Optional origin layer for the error — e.g. `application` when\nthe error came from the remote system the adaptor called,\n`connector` when the adaptor itself rejected the request."}},"required":["message"]}}},"required":["errors"]}},"responses":{"401-unauthorized":{"description":"Unauthorized. The request lacks a valid bearer token, or the provided token\nfailed to authenticate.\n\nNote: the 401 response is produced by the auth middleware **before** the\nrequest reaches the endpoint handler, so it does **not** follow the\nstandard `{errors: [...]}` envelope. Instead the body is a bare\n`{message: string}` object with no `code`, no `errors` array. Callers\nhandling 401s should key off the HTTP status and the `message` string,\nnot try to destructure an `errors[]`.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable description of the auth failure. Known values:\n- `\"Unauthorized\"` — no `Authorization` header on the request.\n- `\"Bearer Authentication Failed\"` — header present but token\n  is invalid, revoked, or expired."}},"required":["message"]}}}}}},"paths":{"/v1/state/{key}":{"put":{"operationId":"setGlobalStateValue","tags":["State"],"summary":"Create or update a global state value","description":"Sets the value for a global state key. Creates the key if it does\nnot exist; replaces the value if it does.\n\nThe request body must be a non-empty JSON object or array. Bare\nJSON primitives (strings, numbers, booleans, `null`) and empty\ncontainers (`{}`, `[]`) are rejected.","parameters":[{"name":"key","in":"path","required":true,"schema":{"type":"string"},"description":"The state key name."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"description":"A non-empty JSON object or array to store. Bare primitives\nand empty containers are not accepted.","oneOf":[{"title":"Object","type":"object","minProperties":1},{"title":"Array","type":"array","minItems":1}]}}}},"responses":{"200":{"description":"Existing key updated.","content":{"text/plain":{"schema":{"type":"string","enum":["OK"]}}}},"201":{"description":"New key created.","content":{"text/plain":{"schema":{"type":"string","enum":["Created"]}}}},"400":{"description":"Invalid request body. The body is not valid JSON, or is a bare\nprimitive (string, number, boolean, or `null`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/401-unauthorized"},"415":{"description":"The `Content-Type` header is missing or is not\n`application/json`.","content":{"application/json":{"schema":{"type":"object","required":["errors"],"properties":{"errors":{"type":"array","items":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}},"422":{"description":"The request body is empty, or is an empty container (`{}` or\n`[]`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Delete a global state key

> Deletes a specific global state key and its value. Returns \`404\`\
> if the key does not exist.

```json
{"openapi":"3.1.0","info":{"title":"State","version":"1.0.0"},"servers":[{"url":"https://api.integrator.io","description":"Production (US / default region)"},{"url":"https://api.eu.integrator.io","description":"Production (EU region)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}},"responses":{"401-unauthorized":{"description":"Unauthorized. The request lacks a valid bearer token, or the provided token\nfailed to authenticate.\n\nNote: the 401 response is produced by the auth middleware **before** the\nrequest reaches the endpoint handler, so it does **not** follow the\nstandard `{errors: [...]}` envelope. Instead the body is a bare\n`{message: string}` object with no `code`, no `errors` array. Callers\nhandling 401s should key off the HTTP status and the `message` string,\nnot try to destructure an `errors[]`.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable description of the auth failure. Known values:\n- `\"Unauthorized\"` — no `Authorization` header on the request.\n- `\"Bearer Authentication Failed\"` — header present but token\n  is invalid, revoked, or expired."}},"required":["message"]}}}}}},"paths":{"/v1/state/{key}":{"delete":{"operationId":"deleteGlobalStateKey","tags":["State"],"summary":"Delete a global state key","description":"Deletes a specific global state key and its value. Returns `404`\nif the key does not exist.","parameters":[{"name":"key","in":"path","required":true,"schema":{"type":"string"},"description":"The state key name."}],"responses":{"204":{"description":"Key deleted."},"401":{"$ref":"#/components/responses/401-unauthorized"},"404":{"description":"The key does not exist.","content":{"application/json":{"schema":{"type":"object","required":["errors"],"properties":{"errors":{"type":"array","items":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}}}}}}}
```

## List state keys for a resource

> Returns the list of state key names stored under the specified\
> resource. These keys are separate from global state.\
> \
> Returns \`204 No Content\` when no keys exist for the resource.\
> \
> Only \`exports\`, \`imports\`, and \`integrations\` support\
> resource-scoped state. Other resource types return \`403\`.

```json
{"openapi":"3.1.0","info":{"title":"State","version":"1.0.0"},"servers":[{"url":"https://api.integrator.io","description":"Production (US / default region)"},{"url":"https://api.eu.integrator.io","description":"Production (EU region)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}},"schemas":{"Error":{"type":"object","description":"Standard error response envelope returned by integrator.io APIs.","properties":{"errors":{"type":"array","description":"List of errors that occurred while processing the request.","items":{"type":"object","properties":{"code":{"oneOf":[{"type":"string"},{"type":"integer"}],"description":"Machine-readable error code. Usually a string like\n`invalid_ref`, `missing_required_field`, or `unauthorized`;\nmay be an **integer** when the error mirrors an upstream HTTP\nstatus (e.g. `500`) — most commonly returned by connection-ping\nand adaptor-proxy responses."},"message":{"type":"string","description":"Human-readable description of the error."},"field":{"type":"string","description":"Optional pointer to the document field that caused the error.\nUsed by structural validation errors (`missing_required_field`,\n`invalid_ref`) to indicate which field is at fault\n(e.g. `_id`, `type`, `http.baseURI`)."},"source":{"type":"string","description":"Optional origin layer for the error — e.g. `application` when\nthe error came from the remote system the adaptor called,\n`connector` when the adaptor itself rejected the request."}},"required":["message"]}}},"required":["errors"]}},"responses":{"401-unauthorized":{"description":"Unauthorized. The request lacks a valid bearer token, or the provided token\nfailed to authenticate.\n\nNote: the 401 response is produced by the auth middleware **before** the\nrequest reaches the endpoint handler, so it does **not** follow the\nstandard `{errors: [...]}` envelope. Instead the body is a bare\n`{message: string}` object with no `code`, no `errors` array. Callers\nhandling 401s should key off the HTTP status and the `message` string,\nnot try to destructure an `errors[]`.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable description of the auth failure. Known values:\n- `\"Unauthorized\"` — no `Authorization` header on the request.\n- `\"Bearer Authentication Failed\"` — header present but token\n  is invalid, revoked, or expired."}},"required":["message"]}}}}}},"paths":{"/v1/{resourceType}/{_resourceId}/state":{"get":{"operationId":"listResourceStateKeys","tags":["State"],"summary":"List state keys for a resource","description":"Returns the list of state key names stored under the specified\nresource. These keys are separate from global state.\n\nReturns `204 No Content` when no keys exist for the resource.\n\nOnly `exports`, `imports`, and `integrations` support\nresource-scoped state. Other resource types return `403`.","parameters":[{"name":"resourceType","in":"path","required":true,"schema":{"type":"string","enum":["exports","imports","integrations"]},"description":"The resource type. Only `exports`, `imports`, and\n`integrations` are supported."},{"name":"_resourceId","in":"path","required":true,"schema":{"type":"string"},"description":"The resource ID."}],"responses":{"200":{"description":"Object containing an array of key names.","content":{"application/json":{"schema":{"type":"object","required":["keys"],"properties":{"keys":{"type":"array","items":{"type":"string"}}}}}}},"204":{"description":"No state keys exist for this resource."},"400":{"description":"The resource ID is not a valid identifier.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/401-unauthorized"},"403":{"description":"The resource type does not support state. Only `exports`,\n`imports`, and `integrations` are allowed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The resource was not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Delete all state keys for a resource

> Deletes \*\*all\*\* state keys and values stored under the specified\
> resource.

```json
{"openapi":"3.1.0","info":{"title":"State","version":"1.0.0"},"servers":[{"url":"https://api.integrator.io","description":"Production (US / default region)"},{"url":"https://api.eu.integrator.io","description":"Production (EU region)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}},"schemas":{"Error":{"type":"object","description":"Standard error response envelope returned by integrator.io APIs.","properties":{"errors":{"type":"array","description":"List of errors that occurred while processing the request.","items":{"type":"object","properties":{"code":{"oneOf":[{"type":"string"},{"type":"integer"}],"description":"Machine-readable error code. Usually a string like\n`invalid_ref`, `missing_required_field`, or `unauthorized`;\nmay be an **integer** when the error mirrors an upstream HTTP\nstatus (e.g. `500`) — most commonly returned by connection-ping\nand adaptor-proxy responses."},"message":{"type":"string","description":"Human-readable description of the error."},"field":{"type":"string","description":"Optional pointer to the document field that caused the error.\nUsed by structural validation errors (`missing_required_field`,\n`invalid_ref`) to indicate which field is at fault\n(e.g. `_id`, `type`, `http.baseURI`)."},"source":{"type":"string","description":"Optional origin layer for the error — e.g. `application` when\nthe error came from the remote system the adaptor called,\n`connector` when the adaptor itself rejected the request."}},"required":["message"]}}},"required":["errors"]}},"responses":{"401-unauthorized":{"description":"Unauthorized. The request lacks a valid bearer token, or the provided token\nfailed to authenticate.\n\nNote: the 401 response is produced by the auth middleware **before** the\nrequest reaches the endpoint handler, so it does **not** follow the\nstandard `{errors: [...]}` envelope. Instead the body is a bare\n`{message: string}` object with no `code`, no `errors` array. Callers\nhandling 401s should key off the HTTP status and the `message` string,\nnot try to destructure an `errors[]`.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable description of the auth failure. Known values:\n- `\"Unauthorized\"` — no `Authorization` header on the request.\n- `\"Bearer Authentication Failed\"` — header present but token\n  is invalid, revoked, or expired."}},"required":["message"]}}}}}},"paths":{"/v1/{resourceType}/{_resourceId}/state":{"delete":{"operationId":"deleteAllResourceState","tags":["State"],"summary":"Delete all state keys for a resource","description":"Deletes **all** state keys and values stored under the specified\nresource.","parameters":[{"name":"resourceType","in":"path","required":true,"schema":{"type":"string","enum":["exports","imports","integrations"]},"description":"The resource type. Only `exports`, `imports`, and\n`integrations` are supported."},{"name":"_resourceId","in":"path","required":true,"schema":{"type":"string"},"description":"The resource ID."}],"responses":{"204":{"description":"All resource state deleted."},"400":{"description":"The resource ID is not a valid identifier.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/401-unauthorized"},"403":{"description":"The resource type does not support state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The resource was not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Get a resource-scoped state value

> Returns the JSON value stored under the given key for a specific\
> resource.\
> \
> Only \`exports\`, \`imports\`, and \`integrations\` support\
> resource-scoped state.

```json
{"openapi":"3.1.0","info":{"title":"State","version":"1.0.0"},"servers":[{"url":"https://api.integrator.io","description":"Production (US / default region)"},{"url":"https://api.eu.integrator.io","description":"Production (EU region)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}},"schemas":{"Error":{"type":"object","description":"Standard error response envelope returned by integrator.io APIs.","properties":{"errors":{"type":"array","description":"List of errors that occurred while processing the request.","items":{"type":"object","properties":{"code":{"oneOf":[{"type":"string"},{"type":"integer"}],"description":"Machine-readable error code. Usually a string like\n`invalid_ref`, `missing_required_field`, or `unauthorized`;\nmay be an **integer** when the error mirrors an upstream HTTP\nstatus (e.g. `500`) — most commonly returned by connection-ping\nand adaptor-proxy responses."},"message":{"type":"string","description":"Human-readable description of the error."},"field":{"type":"string","description":"Optional pointer to the document field that caused the error.\nUsed by structural validation errors (`missing_required_field`,\n`invalid_ref`) to indicate which field is at fault\n(e.g. `_id`, `type`, `http.baseURI`)."},"source":{"type":"string","description":"Optional origin layer for the error — e.g. `application` when\nthe error came from the remote system the adaptor called,\n`connector` when the adaptor itself rejected the request."}},"required":["message"]}}},"required":["errors"]}},"responses":{"401-unauthorized":{"description":"Unauthorized. The request lacks a valid bearer token, or the provided token\nfailed to authenticate.\n\nNote: the 401 response is produced by the auth middleware **before** the\nrequest reaches the endpoint handler, so it does **not** follow the\nstandard `{errors: [...]}` envelope. Instead the body is a bare\n`{message: string}` object with no `code`, no `errors` array. Callers\nhandling 401s should key off the HTTP status and the `message` string,\nnot try to destructure an `errors[]`.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable description of the auth failure. Known values:\n- `\"Unauthorized\"` — no `Authorization` header on the request.\n- `\"Bearer Authentication Failed\"` — header present but token\n  is invalid, revoked, or expired."}},"required":["message"]}}}}}},"paths":{"/v1/{resourceType}/{_resourceId}/state/{key}":{"get":{"operationId":"getResourceStateValue","tags":["State"],"summary":"Get a resource-scoped state value","description":"Returns the JSON value stored under the given key for a specific\nresource.\n\nOnly `exports`, `imports`, and `integrations` support\nresource-scoped state.","parameters":[{"name":"resourceType","in":"path","required":true,"schema":{"type":"string","enum":["exports","imports","integrations"]},"description":"The resource type. Only `exports`, `imports`, and\n`integrations` are supported."},{"name":"_resourceId","in":"path","required":true,"schema":{"type":"string"},"description":"The resource ID."},{"name":"key","in":"path","required":true,"schema":{"type":"string"},"description":"The state key name."}],"responses":{"200":{"description":"The stored value (a JSON object or array).","content":{"application/json":{"schema":{"oneOf":[{"title":"Object","type":"object"},{"title":"Array","type":"array"}]}}}},"400":{"description":"The resource ID is not a valid identifier.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/401-unauthorized"},"403":{"description":"The resource type does not support state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The resource or key was not found.","content":{"application/json":{"schema":{"type":"object","required":["errors"],"properties":{"errors":{"type":"array","items":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}}}}}}}
```

## Create or update a resource-scoped state value

> Sets the value for a state key under a specific resource. Creates\
> the key if it does not exist; replaces the value if it does.\
> \
> The request body must be a non-empty JSON object or array. Bare\
> JSON primitives (strings, numbers, booleans, \`null\`) and empty\
> containers (\`{}\`, \`\[]\`) are rejected.\
> \
> Only \`exports\`, \`imports\`, and \`integrations\` support\
> resource-scoped state.

```json
{"openapi":"3.1.0","info":{"title":"State","version":"1.0.0"},"servers":[{"url":"https://api.integrator.io","description":"Production (US / default region)"},{"url":"https://api.eu.integrator.io","description":"Production (EU region)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}},"schemas":{"Error":{"type":"object","description":"Standard error response envelope returned by integrator.io APIs.","properties":{"errors":{"type":"array","description":"List of errors that occurred while processing the request.","items":{"type":"object","properties":{"code":{"oneOf":[{"type":"string"},{"type":"integer"}],"description":"Machine-readable error code. Usually a string like\n`invalid_ref`, `missing_required_field`, or `unauthorized`;\nmay be an **integer** when the error mirrors an upstream HTTP\nstatus (e.g. `500`) — most commonly returned by connection-ping\nand adaptor-proxy responses."},"message":{"type":"string","description":"Human-readable description of the error."},"field":{"type":"string","description":"Optional pointer to the document field that caused the error.\nUsed by structural validation errors (`missing_required_field`,\n`invalid_ref`) to indicate which field is at fault\n(e.g. `_id`, `type`, `http.baseURI`)."},"source":{"type":"string","description":"Optional origin layer for the error — e.g. `application` when\nthe error came from the remote system the adaptor called,\n`connector` when the adaptor itself rejected the request."}},"required":["message"]}}},"required":["errors"]}},"responses":{"401-unauthorized":{"description":"Unauthorized. The request lacks a valid bearer token, or the provided token\nfailed to authenticate.\n\nNote: the 401 response is produced by the auth middleware **before** the\nrequest reaches the endpoint handler, so it does **not** follow the\nstandard `{errors: [...]}` envelope. Instead the body is a bare\n`{message: string}` object with no `code`, no `errors` array. Callers\nhandling 401s should key off the HTTP status and the `message` string,\nnot try to destructure an `errors[]`.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable description of the auth failure. Known values:\n- `\"Unauthorized\"` — no `Authorization` header on the request.\n- `\"Bearer Authentication Failed\"` — header present but token\n  is invalid, revoked, or expired."}},"required":["message"]}}}}}},"paths":{"/v1/{resourceType}/{_resourceId}/state/{key}":{"put":{"operationId":"setResourceStateValue","tags":["State"],"summary":"Create or update a resource-scoped state value","description":"Sets the value for a state key under a specific resource. Creates\nthe key if it does not exist; replaces the value if it does.\n\nThe request body must be a non-empty JSON object or array. Bare\nJSON primitives (strings, numbers, booleans, `null`) and empty\ncontainers (`{}`, `[]`) are rejected.\n\nOnly `exports`, `imports`, and `integrations` support\nresource-scoped state.","parameters":[{"name":"resourceType","in":"path","required":true,"schema":{"type":"string","enum":["exports","imports","integrations"]},"description":"The resource type. Only `exports`, `imports`, and\n`integrations` are supported."},{"name":"_resourceId","in":"path","required":true,"schema":{"type":"string"},"description":"The resource ID."},{"name":"key","in":"path","required":true,"schema":{"type":"string"},"description":"The state key name."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"description":"A non-empty JSON object or array to store. Bare primitives\nand empty containers are not accepted.","oneOf":[{"title":"Object","type":"object","minProperties":1},{"title":"Array","type":"array","minItems":1}]}}}},"responses":{"200":{"description":"Existing key updated.","content":{"text/plain":{"schema":{"type":"string","enum":["OK"]}}}},"201":{"description":"New key created.","content":{"text/plain":{"schema":{"type":"string","enum":["Created"]}}}},"400":{"description":"Invalid request. The body is not valid JSON, is a bare\nprimitive, or the resource ID is invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/401-unauthorized"},"403":{"description":"The resource type does not support state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The resource was not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"The `Content-Type` header is missing or is not\n`application/json`.","content":{"application/json":{"schema":{"type":"object","required":["errors"],"properties":{"errors":{"type":"array","items":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}},"422":{"description":"The request body is empty, or is an empty container (`{}` or\n`[]`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Delete a resource-scoped state key

> Deletes a specific state key and its value from the resource.\
> Returns \`404\` if the key does not exist.

```json
{"openapi":"3.1.0","info":{"title":"State","version":"1.0.0"},"servers":[{"url":"https://api.integrator.io","description":"Production (US / default region)"},{"url":"https://api.eu.integrator.io","description":"Production (EU region)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}},"schemas":{"Error":{"type":"object","description":"Standard error response envelope returned by integrator.io APIs.","properties":{"errors":{"type":"array","description":"List of errors that occurred while processing the request.","items":{"type":"object","properties":{"code":{"oneOf":[{"type":"string"},{"type":"integer"}],"description":"Machine-readable error code. Usually a string like\n`invalid_ref`, `missing_required_field`, or `unauthorized`;\nmay be an **integer** when the error mirrors an upstream HTTP\nstatus (e.g. `500`) — most commonly returned by connection-ping\nand adaptor-proxy responses."},"message":{"type":"string","description":"Human-readable description of the error."},"field":{"type":"string","description":"Optional pointer to the document field that caused the error.\nUsed by structural validation errors (`missing_required_field`,\n`invalid_ref`) to indicate which field is at fault\n(e.g. `_id`, `type`, `http.baseURI`)."},"source":{"type":"string","description":"Optional origin layer for the error — e.g. `application` when\nthe error came from the remote system the adaptor called,\n`connector` when the adaptor itself rejected the request."}},"required":["message"]}}},"required":["errors"]}},"responses":{"401-unauthorized":{"description":"Unauthorized. The request lacks a valid bearer token, or the provided token\nfailed to authenticate.\n\nNote: the 401 response is produced by the auth middleware **before** the\nrequest reaches the endpoint handler, so it does **not** follow the\nstandard `{errors: [...]}` envelope. Instead the body is a bare\n`{message: string}` object with no `code`, no `errors` array. Callers\nhandling 401s should key off the HTTP status and the `message` string,\nnot try to destructure an `errors[]`.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable description of the auth failure. Known values:\n- `\"Unauthorized\"` — no `Authorization` header on the request.\n- `\"Bearer Authentication Failed\"` — header present but token\n  is invalid, revoked, or expired."}},"required":["message"]}}}}}},"paths":{"/v1/{resourceType}/{_resourceId}/state/{key}":{"delete":{"operationId":"deleteResourceStateKey","tags":["State"],"summary":"Delete a resource-scoped state key","description":"Deletes a specific state key and its value from the resource.\nReturns `404` if the key does not exist.","parameters":[{"name":"resourceType","in":"path","required":true,"schema":{"type":"string","enum":["exports","imports","integrations"]},"description":"The resource type. Only `exports`, `imports`, and\n`integrations` are supported."},{"name":"_resourceId","in":"path","required":true,"schema":{"type":"string"},"description":"The resource ID."},{"name":"key","in":"path","required":true,"schema":{"type":"string"},"description":"The state key name."}],"responses":{"204":{"description":"Key deleted."},"400":{"description":"The resource ID is not a valid identifier.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/401-unauthorized"},"403":{"description":"The resource type does not support state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The resource or key was not found.","content":{"application/json":{"schema":{"type":"object","required":["errors"],"properties":{"errors":{"type":"array","items":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.celigo.com/api/api-reference/state.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
