---
agentTools:
  projectIndex: https://payment-orchestrator.readme.io/llms.txt
---

# Create an API Key

Creates a new **API Key** for a given client. 

If the client has an API Key already assigned, then the previous one will be invalidated and a new key will be generated and returned.

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "version": "v1",
    "title": "Payment API",
    "description": "The Payment API is a service that allows merchants to connect with multiple payment receivers through a single API call.\n"
  },
  "servers": [
    {
      "url": "http://sandbox-planet-oapi-269696318.eu-central-1.elb.amazonaws.com:8080/api",
      "description": "Payment API - Staging"
    }
  ],
  "security": [
    {
      "api-key": []
    }
  ],
  "tags": [
    {
      "name": "ApiKeys",
      "description": "Manage API Keys"
    }
  ],
  "paths": {
    "/v1/api-keys": {
      "post": {
        "tags": [
          "ApiKeys"
        ],
        "security": [],
        "summary": "Create an API Key",
        "operationId": "create-api-key",
        "description": "Creates a new **API Key** for a given client. \n\nIf the client has an API Key already assigned, then the previous one will be invalidated and a new key will be generated and returned.\n",
        "responses": {
          "200": {
            "description": "The request is valid and an API Key was returned.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiKeyRequest"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "BadRequest": {
        "description": "The request is invalid. The specific reason is returned in the response body.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "InternalServerError": {
        "description": "The request is valid but the server could not process it. The specific reason is returned in the response body.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "api-key": {
        "type": "apiKey",
        "name": "API-KEY",
        "in": "header",
        "description": "The API Key to authorize requests."
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "An explanation of the problem that occurred when processing a request [RFC7807].",
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "description": "A URI reference [RFC3986] that identifies the problem type.  This specification encourages that, when dereferenced, it provide human-readable documentation for the problem type (e.g., using HTML [W3C.REC-html5-20141028]).  When this member is not present, its value is assumed to be \"about:blank\".\n",
            "example": "/problems/validation-failed"
          },
          "title": {
            "type": "string",
            "description": "A short, human-readable summary of the problem type.  It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).",
            "example": "The validation for the request has produced errors."
          },
          "status": {
            "type": "integer",
            "description": "The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem. Optional field.",
            "example": 400
          },
          "detail": {
            "type": "string",
            "description": "A human-readable explanation specific to this occurrence of the problem.",
            "example": "The validation of the request failed on field(s) 'A'."
          },
          "errors": {
            "type": "array",
            "nullable": true,
            "description": "A collection of all errors that occurred when processing the request.",
            "items": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "Represents a single error within the application.",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true,
            "description": "The unique error code.",
            "example": "V1234"
          },
          "message": {
            "type": "string",
            "description": "A human-readable message that states the error.",
            "example": "Field A value must be between 1 and 20."
          }
        }
      },
      "ApiKeyRequest": {
        "type": "object",
        "description": "A schema used to request an API Key.",
        "properties": {
          "clientId": {
            "type": "string",
            "description": "The identifier of the requesting client. Can be any valid string.",
            "example": "example123"
          },
          "clientType": {
            "type": "string",
            "description": "The type of the requesting client. Can be any valid string.",
            "example": "merchant"
          }
        },
        "required": [
          "clientId",
          "clientType"
        ]
      },
      "ApiKeyResponse": {
        "type": "object",
        "description": "A schema returned upon a successful API Key request.",
        "properties": {
          "apiKey": {
            "type": "string",
            "nullable": false,
            "description": "The API Key value.",
            "example": "c16f0cfc3a47dea225786fc613f112bc"
          }
        }
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 100,
      "1": 99,
      "2": 95,
      "3": 209,
      "4": 224,
      "5": 111,
      "6": 134,
      "7": 6,
      "8": 133,
      "9": 199,
      "10": 135,
      "11": 133
    }
  }
}
```