{
  "openapi": "3.0.3",
  "info": {
    "title": "Access Keys Management API",
    "license": {
      "name": "MIT",
      "url": "https://www.sinch.com/toc"
    },
    "description": "This API provides programmatic access to manage Access Keys for projects. Access keys can be used to generate access tokens which grant access to other resource APIs.",
    "version": "v1"
  },
  "security": [
    {
      "OAuth2": []
    },
    {
      "Basic": []
    }
  ],
  "paths": {
    "/v1/projects/{projectId}/accessKeys": {
      "get": {
        "tags": [
          "Access Key"
        ],
        "description": "Lists all Access Keys for project.\n",
        "operationId": "AccessKeyService_ListAccessKeys",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "description": "Required. List keys for the provided project.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Optional. The maximum number of results to return in a single response. It\n must be in the range 1-1000. If left empty, a default page size of 100 is\n used.",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageToken",
            "in": "query",
            "description": "Optional. The pagination token returned in an earlier response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListAccessKeysResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/401Error"
          },
          "403": {
            "$ref": "#/components/responses/403Error"
          },
          "500": {
            "$ref": "#/components/responses/500Error"
          },
          "503": {
            "$ref": "#/components/responses/503Error"
          }
        },
        "summary": "List Keys"
      },
      "post": {
        "tags": [
          "Access Key"
        ],
        "description": "Creates an Access Key for the given project. Returns the new key and\n its credentials.\n",
        "operationId": "AccessKeyService_CreateAccessKey",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAccessKey"
              },
              "examples": {
                "createAccessKey": {
                  "$ref": "#/components/examples/CreateAccessKey"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateAccessKeyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/400Error"
          },
          "401": {
            "$ref": "#/components/responses/401Error"
          },
          "403": {
            "$ref": "#/components/responses/403Error"
          },
          "409": {
            "$ref": "#/components/responses/409Error"
          },
          "500": {
            "$ref": "#/components/responses/500Error"
          },
          "503": {
            "$ref": "#/components/responses/503Error"
          }
        },
        "summary": "Create Access Key"
      }
    },
    "/v1/projects/{projectId}/accessKeys/{accessKeyId}": {
      "get": {
        "tags": [
          "Access Key"
        ],
        "description": "Retrieves a single Access Key.\n",
        "operationId": "AccessKeyService_GetAccessKey",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "accessKeyId",
            "in": "path",
            "description": "Required. The ID of the Access Key.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessKey"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/401Error"
          },
          "403": {
            "$ref": "#/components/responses/403Error"
          },
          "404": {
            "$ref": "#/components/responses/404Error"
          },
          "500": {
            "$ref": "#/components/responses/500Error"
          },
          "503": {
            "$ref": "#/components/responses/503Error"
          }
        },
        "summary": "Get Access Key"
      },
      "delete": {
        "tags": [
          "Access Key"
        ],
        "description": "Deletes an Access Key.\nNote: It is currently possible to delete the same Access Key that is used for the delete operation. This means it is possible to delete the last Access Key. In this scenario a new access key needs to be generated in the customer dashbaord,\n",
        "operationId": "AccessKeyService_DeleteAccessKey",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "accessKeyId",
            "in": "path",
            "description": "Required. The ID of the Access Key to be deleted.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {}
          },
          "401": {
            "$ref": "#/components/responses/401Error"
          },
          "403": {
            "$ref": "#/components/responses/403Error"
          },
          "404": {
            "$ref": "#/components/responses/404Error"
          },
          "500": {
            "$ref": "#/components/responses/500Error"
          },
          "503": {
            "$ref": "#/components/responses/503Error"
          }
        },
        "summary": "Delete Access Key"
      },
      "patch": {
        "tags": [
          "Access Key"
        ],
        "description": "Updates an Access Key with new information.\n",
        "operationId": "AccessKeyService_UpdateAccessKey",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "accessKeyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAccessKey"
              },
              "examples": {
                "updateAccessKey": {
                  "$ref": "#/components/examples/UpdateAccessKey"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessKey"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/401Error"
          },
          "403": {
            "$ref": "#/components/responses/403Error"
          },
          "404": {
            "$ref": "#/components/responses/404Error"
          },
          "409": {
            "$ref": "#/components/responses/409Error"
          },
          "500": {
            "$ref": "#/components/responses/500Error"
          },
          "503": {
            "$ref": "#/components/responses/503Error"
          }
        },
        "summary": "Update Access Key"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "Basic": {
        "type": "http",
        "scheme": "basic",
        "description": "For more information about basic authentication, see [Basic Authentication](/docs/accesskeys/api-reference/#basic-authentication)."
      },
      "OAuth2": {
        "type": "oauth2",
        "description": "The user name and password are your client_id and key_secret from the [Access Keys sections](https://dashboard.sinch.com/settings/access-keys)",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://auth.sinch.com/oauth2/token",
            "scopes": {}
          }
        }
      }
    },
    "examples": {
      "CreateAccessKey": {
        "summary": "Create an Access Key for a project.",
        "value": {
          "displayName": "My production Access Key"
        }
      },
      "UpdateAccessKey": {
        "summary": "Update an existing Access Key",
        "value": {
          "displayName": "My staging Access Key"
        }
      }
    },
    "schemas": {
      "protobufAny": {
        "type": "object",
        "properties": {
          "type_url": {
            "type": "string"
          },
          "value": {
            "type": "string",
            "format": "byte"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "integer",
                "format": "int32"
              },
              "details": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/protobufAny"
                }
              },
              "message": {
                "type": "string"
              },
              "status": {
                "type": "string"
              }
            }
          }
        }
      },
      "AccessKey": {
        "type": "object",
        "properties": {
          "accessKeyId": {
            "type": "string",
            "description": "Unique ID for this Access Key."
          },
          "displayName": {
            "type": "string",
            "description": "The display name for this Access Key. It must be unique for the resource tied to the key."
          },
          "projectId": {
            "type": "string",
            "description": "The project ID this key is tied to."
          },
          "createTime": {
            "type": "string",
            "description": "Timestamp when the Access Key was created.",
            "format": "date-time"
          },
          "updateTime": {
            "type": "string",
            "description": "Timestamp when the Access Key was last modified.",
            "format": "date-time"
          }
        },
        "description": "A single Access Key."
      },
      "UpdateAccessKey": {
        "type": "object",
        "properties": {
          "displayName": {
            "type": "string",
            "description": "Required. The display name for this Access Key. It must be unique for the resource tied to the key."
          }
        },
        "description": "Update Access Key request."
      },
      "CreateAccessKey": {
        "type": "object",
        "properties": {
          "displayName": {
            "type": "string",
            "description": "Required. The display name for this Access Key. It must be unique for the resource tied to the key."
          }
        },
        "description": "Update Access Key request."
      },
      "CreateAccessKeyResponse": {
        "type": "object",
        "properties": {
          "accessKey": {
            "allOf": [
              {
                "$ref": "#/components/schemas/AccessKey"
              }
            ],
            "description": "The newly created Access Key."
          },
          "secret": {
            "type": "string",
            "description": "The Access Key secret. After an Access Key has been created it is impossible to\n retrieve its secret again."
          }
        },
        "description": "Response message for the AccessKeyService.CreateAccessKey."
      },
      "ListAccessKeysResponse": {
        "type": "object",
        "properties": {
          "accessKeys": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccessKey"
            },
            "description": "Collection of Access Keys."
          },
          "nextPageToken": {
            "type": "string",
            "description": "The next pagination token, or an empty value if there are no more results."
          }
        },
        "description": "Response message for the AccessKeyService.ListAccessKeysRequest."
      }
    },
    "responses": {
      "400Error": {
        "description": "Malformed request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "invalidArgument": {
                "value": {
                  "error": {
                    "code": 400,
                    "message": "Malformed request",
                    "status": "INVALID_ARGUMENT",
                    "details": []
                  }
                }
              },
              "failedPrecondition": {
                "value": {
                  "error": {
                    "code": 400,
                    "message": "Limit of X Access Keys reached",
                    "status": "FAILED_PRECONDITION",
                    "details": []
                  }
                }
              }
            }
          }
        }
      },
      "401Error": {
        "description": "Unauthenticated. Incorrect credentials."
      },
      "403Error": {
        "description": "Permission denied."
      },
      "404Error": {
        "description": "Resource not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": 404,
                "message": "Not found",
                "status": "NOT_FOUND",
                "details": []
              }
            }
          }
        }
      },
      "409Error": {
        "description": "Conflict",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": 409,
                "message": "Not found",
                "status": "ALREADY_EXISTS",
                "details": []
              }
            }
          }
        }
      },
      "500Error": {
        "description": "Internal error, try again with exponential back-off",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": 500,
                "message": "There was an internal server error.",
                "status": "INTERNAL_ERROR",
                "details": []
              }
            }
          }
        }
      },
      "503Error": {
        "description": "Unavailable, try again with exponential back-off",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": 501,
                "message": "There was an internal server error.",
                "status": "UNAVAILABLE",
                "details": []
              }
            }
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Access Key",
      "description": "Manage Access Keys"
    }
  ],
  "servers": [
    {
      "url": "https://account.api.sinch.com"
    }
  ]
}