This page describes how to use Service Infrastructure for checking
status on [managed services](https://docs.cloud.google.com/service-infrastructure/docs/glossary.md.txt#managed),
[service producers](https://docs.cloud.google.com/service-infrastructure/docs/glossary.md.txt#producer),
[service consumers](https://docs.cloud.google.com/service-infrastructure/docs/glossary.md.txt#consumer), and API keys.

When a service producer offers a service to its service consumers, it needs to
ensure that various preconditions are met, such as whether:

- A service consumer has been deleted.
- The service consumer has [enabled](https://docs.cloud.google.com/service-infrastructure/docs/glossary.md.txt#enabled) the service.
- An API key is valid.

The Service Control API provides a simple
[`services.check`](https://docs.cloud.google.com/service-infrastructure/docs/service-control/reference/rest/v1/services/check.md.txt)
method to check such preconditions. A managed service should call this method on
a regular basis to ensure the preconditions are met. The activity between the
service producer and the service consumer is represented by an
[`Operation`](https://docs.cloud.google.com/service-infrastructure/docs/service-control/reference/rest/v1/Operation.md.txt).
The `services.check` method performs the following checks on the operation:

- The service producer project is live and in a healthy state.
- The service consumer project is live and in a healthy state.
- The managed service is enabled on the service consumer project.
- The API key is valid.
- The use of the API key satisfies restrictions associated with the API key, such as IP or HTTP referrer restrictions.

The `services.check` method is typically called from the servers that actually
implement the service. For security and privacy purposes,
the Service Control API uses [Identity and Access Management](https://docs.cloud.google.com/iam) to verify the
caller has the proper permission to call the method. For details, see
[Service Control API Access Control](https://docs.cloud.google.com/service-infrastructure/docs/service-control/access-control.md.txt).

## Checking status

After you [roll out](https://docs.cloud.google.com/service-infrastructure/docs/glossary.md.txt#rollout) a managed service, you can call the
`services.check` method on the service without additional configuration. See the
[`services.check`](https://docs.cloud.google.com/service-infrastructure/docs/service-control/reference/rest/v1/services/check.md.txt)
reference for details.

To quickly experiment with the method, you can use the `gcurl` command to call
the `services.check` method. See
[Getting Started with the Service Control API](https://docs.cloud.google.com/service-infrastructure/docs/service-control/getting-started.md.txt)
for the initial setup steps.

```
gcurl -d '{
  "operation": {
    "operationId": "123e4567-e89b-12d3-a456-426655440000",
    "consumerId": "project:endpointsapis-consumer",
    "startTime":"2016-07-31T05:20:00Z",
    "operationName":"google.example.hello.v1.HelloService.GetHello"
  }
}' https://servicecontrol.googleapis.com/v1/services/endpointsapis.appspot.com:check
{
  "operationId": "123e4567-e89b-12d3-a456-426655440000"
}
```

The response from the check method indicates whether all checks succeeded or
some checks failed. Success is indicated by the absence of
[`checkErrors`](https://docs.cloud.google.com/service-infrastructure/docs/service-control/reference/rest/v1/services/check.md.txt#CheckError)
field. Otherwise, the `checkErrors` field lists the failed checks.