Creates an ApiKey used to connect OData v4 compliant applications to Data Access endpoints.
The generated apiKey can be used in the password field of Basic authentication in applications or scipts, or used directly in the Authorization header of a request: Authorization: Basic {apiKey}.
ApiKeys are valid for a maximum of 6 months and not extendable. ApiKeys must be rotated when they expire.
Authentication
Requires Authorization header with valid Bearer token for scope itwin-platform.
The ApiKey endpoints cannot be used with access tokens generated using the Try it out feature. Only tokens generated using a registered application are permitted.
For more documentation on authorization and how to get access token visit OAUTH2 Authorization page.
Authorization
User must have insights_view permission(s) assigned at the iTwin level. iModel specific permissions may also be applied at the iModel level if iModel level permissions are enabled.
Alternatively the user should be an Organization Administrator for the Organization that owns a given iTwin or iModel.
An Organization Administrator must have at least one of the following roles assigned in User Management: Account Administrator, Co-Administrator, or CONNECT Services Administrator. For more information about User Management please visit our Bentley Communities Licensing, Cloud, and Web Services wiki page.
Rate limits
All iTwin Platform API operations have a rate limit. For more documentation on that visit Rate limits and quotas page.
Request headers
OAuth access token with itwin-platform scope
Setting to application/vnd.bentley.itwin-platform.v2+json is recommended.
Request body
ApiKey (create)
The Report Id this ApiKey will be created for.
ApiKey expiration DateTime.
Name of the ApiKey.
Example
{ "displayName": "iModel Report ApiKey", "reportId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "expiresAt": "2022-09-02T12:03:00.0000000+00:00" }
Response 201 Created
Created a new ApiKey successfully.
{ "key": { "apiKey": "SecretApiKey", "id": "7abd419f-a01d-483c-9242-eaf98c348fbf", "displayName": "iModel Report ApiKey", "userEmail": "john.doe@example.com", "expiresAt": "2022-09-02T12:03:00.0000000+00:00", "_links": { "report": { "href": "https://api.bentley.com/insights/reporting/reports/3fa85f64-5717-4562-b3fc-2c963f66afa6" } } } }
Response 401 Unauthorized
This response indicates that request lacks valid authentication credentials. Access token might not been provided, issued by the wrong issuer, does not have required scopes or request headers were malformed.
{ "error": { "code": "HeaderNotFound", "message": "Header Authorization was not found in the request. Access denied." } }
Response 422 Unprocessable Entity
The 422 (Unprocessable Entity) status code indicates that the request cannot be processed by the server due to a client error (e.g. malformed request syntax)
{ "error": { "code": "InvalidInsightsRequest", "message": "Cannot create ApiKey.", "details": [{ "code": "InvalidValue", "message": "Provided 'displayName' value is not valid. The value cannot be empty or consist only of whitespace characters.", "target": "displayName" }] } }
Response 429 Too many requests
This response indicates that the client sent more requests than allowed by this API for the current tier of the client.
{ "error": { "code": "RateLimitExceeded", "message": "The client sent more requests than allowed by this API for the current tier of the client." } }
Response headers
Number of seconds to wait until client is allowed to make more requests.
Link
Hyperlink container.
Hyperlink to the specific entity.
{ "type": "object", "title": "Link", "properties": { "href": { "type": "string", "description": "Hyperlink to the specific entity." } }, "description": "Hyperlink container.", "additionalProperties": false }
Error
Contains error information.
One of a server-defined set of error codes.
The target of the error.
A human-readable representation of the error.
{ "type": "object", "required": [ "code", "message" ], "properties": { "code": { "type": "string", "description": "One of a server-defined set of error codes." }, "target": { "type": "string", "nullable": true, "description": "The target of the error." }, "message": { "type": "string", "description": "A human-readable representation of the error." } }, "description": "Contains error information.", "additionalProperties": true }
ApiKey Links
Contains contextual hyperlinks to related data.
{ "type": "object", "title": "ApiKey Links", "required": [ "report" ], "properties": { "report": { "$ref": "#/components/schemas/Link" } }, "description": "Contains contextual hyperlinks to related data.", "additionalProperties": false }
ApiKey (create)
Properties of the ApiKey to be created.
The Report Id this ApiKey will be created for.
ApiKey expiration DateTime.
Name of the ApiKey.
{ "type": "object", "title": "ApiKey (create)", "required": [ "displayName", "reportId" ], "properties": { "reportId": { "type": "string", "description": "The Report Id this ApiKey will be created for." }, "expiresAt": { "type": "string", "format": "date-time", "nullable": true, "description": "ApiKey expiration DateTime." }, "displayName": { "type": "string", "description": "Name of the ApiKey." } }, "description": "Properties of the ApiKey to be created.", "additionalProperties": false }
DetailedError
Contains error information and an array of more specific errors.
One of a server-defined set of error codes.
The target of the error.
A human-readable representation of the error.
{ "type": "object", "required": [ "code", "message", "details" ], "properties": { "code": { "type": "string", "description": "One of a server-defined set of error codes." }, "target": { "type": "string", "nullable": true, "description": "The target of the error." }, "details": { "type": "array", "items": { "$ref": "#/components/schemas/Error" }, "description": "Optional array of more specific errors." }, "message": { "type": "string", "description": "A human-readable representation of the error." } }, "description": "Contains error information and an array of more specific errors.", "additionalProperties": true }
Error Response
Gives details for an error that occurred while handling the request. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.
{ "type": "object", "title": "Error Response", "required": [ "error" ], "properties": { "error": { "$ref": "#/components/schemas/Error", "description": "Error information." } }, "description": "Gives details for an error that occurred while handling the request. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.", "additionalProperties": false }
ApiKey
Properties of the created ApiKey.
The ApiKey Id.
The Key value.
ApiKey expiration DateTime.
Email of the user who created the ApiKey.
Name of the ApiKey.
{ "type": "object", "title": "ApiKey", "required": [ "apiKey", "id", "displayName", "userEmail", "expiresAt", "_links" ], "properties": { "id": { "type": "string", "description": "The ApiKey Id." }, "_links": { "$ref": "#/components/schemas/ApiKey_Links" }, "apiKey": { "type": "string", "description": "The Key value." }, "expiresAt": { "type": "string", "format": "date-time", "description": "ApiKey expiration DateTime." }, "userEmail": { "type": "string", "description": "Email of the user who created the ApiKey." }, "displayName": { "type": "string", "description": "Name of the ApiKey." } }, "description": "Properties of the created ApiKey.", "additionalProperties": false }
Created ApiKey Response
Container for a created ApiKey object.
{ "type": "object", "title": "Created ApiKey Response", "required": [ "key" ], "properties": { "key": { "$ref": "#/components/schemas/ApiKey_Created" } }, "description": "Container for a created ApiKey object.", "additionalProperties": false }
Detailed Error Response
Gives details for an error that occurred while handling the request. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.
{ "type": "object", "title": "Detailed Error Response", "required": [ "error" ], "properties": { "error": { "$ref": "#/components/schemas/DetailedError", "description": "Error Detailed information." } }, "description": "Gives details for an error that occurred while handling the request. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.", "additionalProperties": false }
Was this page helpful?