About the API

Authentication and authorization

The APIs uses a JWT bearer token for authentication. The token is provided by trusted authorities. Currently two authorities are trusted:

  1. STS (managed by ICS)

  2. PRISMAhome (managed by R&D)

There are two ways to get a token from an authority:

  1. Logon interactively to an application which is trusted by the authority.

  2. Generate a token based on a client id and secret.

Get a token using an interactive logon

Interactive logons are typically used for web applications. So, if you are the owner of a web application and want to call the service APIs in the context of the user you need this. When a user navigates to your web application, the user should be redirected to the authority. The authority will handle the authentication of the user. When the authentication is successful, you will get a token of the user which you can use to call the service APIs.

If you want to get a token using interactive logon, the authority owner needs to be contacted: the authority should trust your application.

If your application belongs to the R&D program, you should contact R&D and create a request to make PRISMAhome trust your application.

If you want to use the STS Authority you should create a TopDesk call and create a request to trust your application. If you don’t have access to TopDesk, contact ST&A (Service Tools and Applications) on the following address: spm-servicetooling@cpp.canon. In the request also specify the environment: QA and\or PROD.

Generate a token using a client id and secret

Client id and secret are called credentials. Tokens based on a client id and secret or also known as machine-to-machine tokens. This is typically used when you create a background job or daemon.

If your application belongs to the R&D program you should contact R&D to get the credentials to generate a token.

If you want to use the STS Authority you should create a TopDesk call to get the credentials to generate a token. If you don’t have access to TopDesk, contact ST&A (Service Tools and Applications) on the following address: spm-servicetooling@cpp.canon.
In the request specify which access you need. For example, create a request to get credentials to be able to query service data for machines in EMEA. Also specify the environment: QA and\or PROD. Each environment has its own tokens.

Using your client id and secret you can create a token using the following curl commands:

QA

curl --location --request GET 'https://sts.qa.cppinter.net/adfs/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: BIGipServersts.qa.cppinter.net_pool=2886126090.47873.0000'
--data-urlencode 'client_id=XXXX' \
--data-urlencode 'client_secret=YYYY' \
--data-urlencode 'grant_type=client_credentials'

PROD

curl --location --request GET 'https://sts.cpp.canon/adfs/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: BIGipServersts.qa.cppinter.net_pool=2886126090.47873.0000'
--data-urlencode 'client_id=XXXX' \
--data-urlencode 'client_secret=YYYY' \
--data-urlencode 'grant_type=client_credentials'

Span of control

The data returned from the API is based on the user's service organization and assigned roles. A user can only view and/or edit data he or she has the rights to. We call this span of control, SOC. Beside user roles and the service organization of a user, system configuration or settings can make it so that specific data falls outside the users SOC.

For example, a service organization can have the configuration flag 'MIF visible' set to false. 'MIF Visible' stands for 'machines in field visible'. When set to false, users from a parent service organization cannot see the devices.

When it looks like there is data missing, always double-check the user roles and system configuration.

User roles

Endpoints on the API can need different user roles. What user roles are needed for a given endpoint are documented in the SwaggerUI, see screenshot.

Using the API in your application

OpenAPI

This API is built with the OpenAPI specification in mind. This means that, regardless of the programming language you choose, you can use tools like those provided by Swagger to generate API client code. Documentation for the swagger code gen can be found here.
More about OpenApi can be found here.

If you need help implementing the API, contact ST&A (Service Tools and Applications) on the following address: spm-servicetooling@cpp.canon.

Throttling

To ensure consistent performance the APIs use throttling. When you get throttled a 429 “Too many requests” is returned. The response also contains a header “retry-after” this contains the time to wait in seconds before you are free to send requests again until you get throttled again.

Making a call to an API

Using CURL

The following call requests an active device printheads that have serialnumber '123456'

curl -X 'GET' \
'https://serviceapi.qa.cppinter.net/warranty/v23.06/ActiveDevicePrintheads?deviceSerialNumber=123456' \
-H 'accept: application/json' \
-H 'Authorization: Bearer {{access_token}}

  • access_token: token from authentication request.

FAQ

I want to have access to the API. Where do I request login credentials for me or my organization?

You can request credentials at ST&A (Service Tools and Applications) you can contact them on the following address: spm-servicetooling@cpp.canon

What could be causing data 'x' or 'y' to not be returned as expected?

It could be that that the expected data does not fall into the users span of control. Please double check that the given device is correctly configured.

Why is authorization denied when using the SwaggerUI web interface?

A common mistake when using the SwaggerUI web interface, is to forget the word 'bearer' in front of token string in the 'Authorization' input field. See image below.