{
  "openapi": "3.0.3",
  "info": {
    "title": "Client Credentials Management service",
    "version": "v1",
    "description": ""
  },
  "servers": [
    {
      "url": "https://cloud.kaaiot.com/ccm/api/v1",
      "description": "API Server"
    }
  ],
  "paths": {
    "/basic-credentials": {
      "get": {
        "description": "Returns a list of basic client credentials in the scope of the requested tenant.",
        "responses": {
          "200": {
            "description": "Response 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": [
                  {
                    "username": "UserA",
                    "id": "br7si8mg10l7an82que0",
                    "state": "Inactive",
                    "createdDate": "2020-03-01T12:47:02.247462Z",
                    "updatedDate": "2020-04-17T12:00:01.311853Z"
                  },
                  {
                    "username": "UserB",
                    "id": "br7si8mg10l7an82queg",
                    "state": "Active",
                    "createdDate": "2020-04-02T12:47:02.247941Z",
                    "updatedDate": "2020-04-12T13:00:01.311934Z",
                    "lastUseDate": "2020-06-16T16:01:07.090941Z"
                  },
                  {
                    "username": "UserC",
                    "id": "br7si8mg10l7an82quf0",
                    "state": "Suspended",
                    "createdDate": "2020-05-03T12:47:02.247752Z",
                    "updatedDate": "2020-05-12T12:00:01.311835Z",
                    "lastUseDate": "2020-06-16T16:01:07.090941Z"
                  }
                ]
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "tenant:basic-credentials:read on tenant-system resource"
            ]
          }
        ]
      },
      "post": {
        "description": "Creates new basic credentials.",
        "responses": {
          "201": {
            "description": "Credentials created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BasicCredentialsCreationResponse"
                },
                "example": {
                  "username": "reasonable-kangaroo",
                  "password": "deta7IWaHohNo4Uunoorei7OIk3OC3Ot",
                  "id": "bg7si8mg10l7an82que0",
                  "state": "Inactive",
                  "createdDate": "2020-03-01T12:47:02.247962Z",
                  "updatedDate": "2020-04-17T12:00:01.311923Z"
                }
              }
            }
          },
          "400": {
            "description": "Username or password is not valid."
          },
          "409": {
            "description": "Basic credentials with such username already registered."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "tenant:basic-credentials:create"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BasicCredentialsCreationRequest"
              }
            }
          }
        }
      }
    },
    "/basic-credentials/{id}/state": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Unique identifier of the basic credentials.",
          "example": "efh63sad72g0sggo3s5a"
        }
      ],
      "patch": {
        "description": "Updates credentials state.\nCCM maintains a credentials state machine summarized in the service documentation.\nOnly transitions from/to specified states are permitted.\n",
        "responses": {
          "204": {
            "description": "Successfully updated credentials state."
          },
          "404": {
            "description": "The requested basic credentials are not found or the querying user is denied access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "tenant:basic-credentials:update"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CredentialsStateUpdate"
              },
              "example": {
                "state": "Suspended"
              }
            }
          }
        }
      }
    },
    "/basic-credentials/{id}/password": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Unique identifier of the basic credentials.",
          "example": "efh63sad72g0sggo3s5a"
        }
      ],
      "patch": {
        "description": "Resets basic credentials password.",
        "responses": {
          "200": {
            "description": "Password is successfully reset.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BasicCredentialsPasswordResetResponse"
                },
                "example": {
                  "password": "mQ8jSA3Cywbs7cLJ"
                }
              }
            }
          },
          "400": {
            "description": "Password is not valid."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "tenant:basic-credentials:update"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CredentialsPasswordReset"
              },
              "example": {
                "password": "mQ8jSA3Cywbs7cLJ"
              }
            }
          }
        }
      }
    },
    "/x509-credentials": {
      "get": {
        "description": "Returns a list of client X.509 credentials in the scope of the requested tenant.",
        "responses": {
          "200": {
            "description": "Response 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": [
                  {
                    "id": "bg7si8mg10l7an82que0",
                    "state": "Inactive",
                    "serialNumber": "8163249196696785795007161035531673258207322822",
                    "commonName": "silver-advice",
                    "invalidAfter": "2025-07-01T12:48:09.247962Z",
                    "createdDate": "2020-03-01T12:47:02.247962Z",
                    "updatedDate": "2020-04-17T12:00:01.311923Z"
                  },
                  {
                    "id": "bg7si8mg10l7an82quh4",
                    "state": "Active",
                    "serialNumber": "8163249196696785795007161035531673258207322829",
                    "commonName": "silver-advice",
                    "invalidAfter": "2025-07-01T12:48:09.247962Z",
                    "createdDate": "2020-03-01T12:47:02.247962Z",
                    "updatedDate": "2020-04-17T12:00:01.311923Z",
                    "lastUseDate": "2020-06-16T16:01:07.090941Z"
                  },
                  {
                    "id": "bg7si8mg10l7an82quk2",
                    "state": "Suspended",
                    "serialNumber": "8163249196696785795007161035531673258207322821",
                    "commonName": "silent-kangaroo",
                    "invalidAfter": "2025-07-01T12:48:09.247962Z",
                    "createdDate": "2020-03-01T12:47:02.247962Z",
                    "updatedDate": "2020-04-17T12:00:01.311923Z",
                    "lastUseDate": "2020-06-16T16:01:07.090941Z"
                  }
                ]
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "tenant:x509-credentials:read on tenant-system resource"
            ]
          }
        ]
      },
      "post": {
        "description": "Issue a client X.509 credentials in the scope of the requested tenant.",
        "responses": {
          "201": {
            "description": "Credentials issued successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "certificate": "-----BEGIN CERTIFICATE-----\nMIIDPDCCAiSgAwIBAgIUeMV9wzZ+GjCwQRdoMgaKJkegmhQwDQYJKoZIhvcNAQEL\nBQAwEzERMA8GA1UEAxMIdGVuYW50LTEwHhcNMjAw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LqL61geP20QN3ClWJ2M8kPc3Nd9RXSgyOJyunjM5+LCFWxukpH7zhbtKrvbK\nmCD14iCpVQ==\n-----END CERTIFICATE-----",
                  "privateKey": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA4Oxmgvjb1zLcQsYbln8BUDf4+1Ham1fDWHYnruQcJkTCa+/N\nRbRkJXXloo3jUaOSbOHlSA2T7/dYCpE5FvdX0O/5XLH+/83LfDRmjYhEcYZdtokM\n05n3cK4gjVB+qTJd+FRopgHrpGABrt2z+x5yOJaDQgR6RokWe8Z4NTpSX4EPD6DF\nr97x3wFZCzwukpteazO7sHoWARJdvEto/sZf3Z0ekyo5ABxDG68pSpkZAQy9J1LE\n7lYRwWX5I2seguUA5JbLENJAQHpZLKFI2TZZo7UrCVmHyAViWvBGi57Nex0yC+lN\nffY38Tc4CUAFwZmenXaaiKO3bmJSovEfXDACrwIDAQABAoIBAQDaEdlB2m2qs1EC\nHHja7MAlOl9XqwC749ctiUDoO5lfMQMfCxyGHGOMPkYp2E8w89ofXtShiyiHW9Qs\nSqiDL8QgesnVqW2GLcy/2z4isp9JQfDR7QZWkcxpnylIWWa0PHUHMy9S5EHG2J5J\nIAJD0j0DyEnyU80JXhhCYSZi1OzQUcrO97ejPf3XkadMNVyF8eP+sh+2o6+q7Wwg\nTb7oqgTk17DUwxzzciCdWdXnmvxFlxncPswNbOBE2KL4M2/VelNjnyhjX/l4G1f1\ngDV7Id3gc/H/MKY023F1FhsiRvFGHE5s7izKQrfZamQMJMU11dcyVslRXvp4vf2+\n+gI0p3ahAoGBAPnMoUX2CT77mNgLRRJ5uMHkFeDctX84Zqc9GlukRjDV03AovAnm\nJq7WVB+xnHqOuYoCaasSWCtG25ONhLnx9oxXtEDo7VUAHtOegjv5A9ED8HH25+Rj\nQ2TNOgvMnihm2KjmV5y1YEbD76rT7+lki5XO0QbLNKTmsI+leykm0xOlAoGBAOaB\nsc9kAupaS/ejGmqmCLeyXOwmDssJd9b+2ouo4mdHfcj9KlA1iYW0TaHSa4dRa0NP\nnWdcB0G8VoEsJ4ArO1tF2ijOVkpZwLZ2m4yYrY7RwJ6hI5FKGHVrxg3pClUPUFSS\nabuD0kmSWVZrmpe8XiA9KULOPdKyRUKG4ai6mhzDAoGAYZKToB81h1uBXUoxpcDT\n8TBld1rerh3awxJz/D3TiPnMyC+xG3DBxWNEosiepaSgRo8gtUjKFcVsuVr68CLa\nOgF8ECqroZsVb3Wny0M+QWN3hRx7gdNgHLypIri/QmrB0F+A815Jh/q64BA+0vyK\nJW8OaMfw/UR6zPFHhVB7/F0CgYAsKI5yx5sTYEcLYtCtu68R2faZOtU8qkyuAFbH\nyIvO81Ayj+VqRkdZOOhiZtg4rS1aUMc7xNKTEkyUJGxQzndpjeE0TgsT5UvY6LH1\n5k3hfWdkPER/Ee3LmODxS0KyduORwBbHWIKRm5rHxodwKCL0FCNya+ZGFebUztgu\nJcleVwKBgQCpRCBQLp6so30jOiNh4BU7f5Tti66bAfQGn7COlHrNKm2W254g4lnL\nscKbeNpt1bNSNVCvDhwCCQRHqD73VV52ZMGTsxS4oOrl3x9/yWLv2YUZIbRGku+g\nIhfQQOdJ+JAWQMcN5dJQ41Bb8TpJS1KPgq+Bl5Xc9UGNUuoU06dYHg==\n-----END RSA PRIVATE KEY-----",
                  "privateKeyType": "rsa",
                  "serialNumber": "8163249196696785795007161035531673258207322829",
                  "commonName": "silver-advice"
                }
              }
            }
          },
          "400": {
            "description": "Common name or invalid after date is not valid."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "tenant:x509-credentials:create on tenant-system resource"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/X509CredentialsCreationRequest"
              }
            }
          }
        }
      }
    },
    "/x509-credentials/{id}/state": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Unique identifier of the X.509 credentials.",
          "example": "efh63sad72g0sggo3s5a"
        }
      ],
      "patch": {
        "description": "Updates credentials state.\nCCM maintains a credentials state machine summarized in the service documentation.\nOnly transitions from/to specified states are permitted.\n",
        "responses": {
          "204": {
            "description": "Successfully updated credentials state."
          },
          "404": {
            "description": "The requested X.509 credentials are not found or the querying user is denied access.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "tenant:x509-credentials:update"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "state": "Suspended"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "oauth_2_0": {
        "type": "oauth2",
        "description": "CCM supports OAuth 2.0 for authenticating most API requests.\n",
        "flows": {
          "implicit": {
            "authorizationUrl": "https://auth.example.com/oauth/authorize",
            "scopes": {}
          }
        }
      }
    },
    "schemas": {
      "BasicCredentialsCreationRequest": {
        "type": "object",
        "properties": {
          "username": {
            "type": "string",
            "description": "Tenant-wide unique username (login).\nUp to 255 ASCII symbols long (except of `:` and `@` symbols, which are not allowed).\n**It is not recommended to use any Personally Identifiable Information (PII) in a username**.\nIf a username is not specified, (a silly) one is auto-generated from over 2 million combinations and returned in the successful response.\n"
          },
          "password": {
            "type": "string",
            "description": "Password matching the given username.\nMust consist of up to 72 ASCII symbols.\nIf not specified, one is auto-generated and returned in the successful response.\n"
          }
        }
      },
      "BasicCredentialsCreationResponse": {},
      "CredentialsStateUpdate": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "description": "Desired new client credentials state.\n<p>\n<ul>\n  <li>`Active` - The credentials are valid for use. They have been used at least once.</li>\n  <li>`Suspended` - The credentials are suspended and cannot be used now.</li>\n  <li>`Revoked` - The credentials are no longer usable.</li>\n</ul>\n",
            "enum": [
              "Active",
              "Suspended",
              "Revoked"
            ]
          }
        },
        "required": [
          "state"
        ]
      },
      "ClientErrorResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Detailed error description."
          }
        },
        "required": [
          "message"
        ]
      },
      "CredentialsPasswordReset": {
        "type": "object",
        "properties": {
          "password": {
            "type": "string",
            "description": "New password.\nMust consist of up to 72 ASCII symbols.\nIf not specified, one is auto-generated and returned in the successful response.\n"
          }
        }
      },
      "BasicCredentialsPasswordResetResponse": {
        "type": "object",
        "properties": {
          "password": {
            "type": "string",
            "description": "Password matching the given credentials."
          }
        },
        "required": [
          "password"
        ]
      },
      "X509CredentialsCreationRequest": {
        "type": "object",
        "properties": {
          "commonName": {
            "type": "string",
            "description": "Certificate Common Name (CN).\nMust consist of up to 255 ASCII symbols.\nIf a CN is not specified, (a silly) one is auto-generated from over 2 million combinations.\n"
          },
          "ttl": {
            "type": "number",
            "description": "The time to leave duration for the certificate in seconds.\nDefaults to 31536000 (365 days) if not specified.\nMust be greater than zero.\n"
          }
        }
      },
      "CredentialsState": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "description": "Client credentials state.\n<p>\n<ul>\n  <li>`Active` - The credentials are valid for use. They have been used at least once.</li>\n  <li>`Inactive` - The credentials are valid for use. They have not been used by any client yet.</li>\n  <li>`Suspended` - The credentials are suspended and cannot be used now.</li>\n  <li>`Revoked` - The credentials are no longer usable.</li>\n</ul>\n",
            "enum": [
              "Active",
              "Inactive",
              "Suspended",
              "Revoked"
            ]
          }
        },
        "required": [
          "state"
        ]
      },
      "BasicCredentials": {
        "type": "object",
        "properties": {
          "username": {
            "type": "string",
            "description": "Tenant-wide unique username (login)."
          },
          "id": {
            "type": "string",
            "description": "Unique identifier of the basic credentials."
          },
          "createdDate": {
            "type": "string",
            "format": "rfc3339",
            "description": "Credentials creation time and date in ISO 8601 format."
          },
          "updatedDate": {
            "type": "string",
            "format": "rfc3339",
            "description": "Last time when the credentials were updates in ISO 8601 format."
          },
          "lastUseDate": {
            "type": "string",
            "format": "rfc3339",
            "description": "Last time when the credentials were used for authentication."
          }
        },
        "required": [
          "username",
          "id",
          "createdDate",
          "updatedDate"
        ]
      },
      "X509Credentials": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the certificate."
          },
          "serialNumber": {
            "type": "string",
            "description": "Certificate serial number, base 10 encoded."
          },
          "commonName": {
            "type": "string",
            "description": "Certificate Common Name (CN)."
          },
          "invalidAfter": {
            "type": "string",
            "format": "rfc3339",
            "description": "The time and date past which the certificate is no longer valid in ISO 8601 format."
          },
          "createdDate": {
            "type": "string",
            "format": "rfc3339",
            "description": "Certificate creation time and date in ISO 8601 format."
          },
          "updatedDate": {
            "type": "string",
            "format": "rfc3339",
            "description": "Last time when the certificate was updates in ISO 8601 format."
          },
          "lastUseDate": {
            "type": "string",
            "format": "rfc3339",
            "description": "Last time when the certificate was used for authentication in ISO 8601 format."
          }
        },
        "required": [
          "id",
          "serialNumber",
          "commonName",
          "invalidAfter",
          "createdDate",
          "updatedDate"
        ]
      }
    }
  }
}