{
    "openapi": "3.0.0",
    "info": {
        "title": "Company URL Entry API",
        "version": "1.0.0"
    },
    "paths": {
        "/api/url_entry": {
            "get": {
                "summary": "List active, unexpired company URL entries",
                "operationId": "get_api_url_entry_list",
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/components/schemas/UrlEntry"
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    }
                }
            },
            "post": {
                "summary": "Create a company URL entry",
                "operationId": "post_api_url_entry_create",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CreateUrlEntry"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "URL entry created",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlEntry"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidPayload"
                    },
                    "409": {
                        "$ref": "#/components/responses/UriConflict"
                    }
                }
            }
        },
        "/api/url_entry/{uuid}": {
            "get": {
                "summary": "Get a company URL entry",
                "operationId": "get_api_url_entry_get",
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlEntry"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            },
            "delete": {
                "summary": "Deactivate a company URL entry",
                "operationId": "delete_api_url_entry_delete",
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "204": {
                        "description": "URL entry deactivated"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        },
        "/api/url_entry/{uuid}/features": {
            "put": {
                "summary": "Replace URL entry features",
                "description": "Omitted features reset to their defaults.",
                "operationId": "put_api_url_entry_features",
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/UrlEntryFeatures"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlEntry"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidPayload"
                    }
                }
            },
            "patch": {
                "summary": "Update selected URL entry features",
                "description": "Omitted features keep their current values.",
                "operationId": "patch_api_url_entry_features",
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/UrlEntryFeatures"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlEntry"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidPayload"
                    }
                }
            }
        },
        "/api/url_entry/{uuid}/url": {
            "put": {
                "summary": "Change the destination URL",
                "operationId": "put_api_url_entry_destination",
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/UrlEntryDestination"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlEntry"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidPayload"
                    }
                }
            },
            "patch": {
                "summary": "Change the destination URL",
                "operationId": "patch_api_url_entry_destination",
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/UrlEntryDestination"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlEntry"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidPayload"
                    }
                }
            }
        },
        "/api/url_entry/{uuid}/statictics": {
            "get": {
                "summary": "Get URL entry visit statistics",
                "operationId": "get_api_url_entry_statictics",
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlEntryStatistics"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        },
        "/api/url_entry/{uuid}/statistics": {
            "get": {
                "summary": "Get URL entry visit statistics",
                "operationId": "get_api_url_entry_statistics",
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlEntryStatistics"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "UrlEntry": {
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "uuid": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "url": {
                        "type": "string",
                        "format": "uri",
                        "example": "https://example.com/products",
                        "maxLength": 2048
                    },
                    "uri": {
                        "type": "string"
                    },
                    "createdAt": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "availableFrom": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "availableTo": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    },
                    "hasPassword": {
                        "type": "boolean"
                    },
                    "isSingleUse": {
                        "type": "boolean"
                    },
                    "isActive": {
                        "type": "boolean"
                    }
                },
                "type": "object"
            },
            "CreateUrlEntry": {
                "required": [
                    "url"
                ],
                "properties": {
                    "url": {
                        "type": "string",
                        "format": "uri",
                        "example": "https://example.com/products",
                        "maxLength": 2048
                    },
                    "uri": {
                        "description": "Omit to generate a short URI.",
                        "type": "string",
                        "pattern": "^[a-zA-Z0-9]{1,255}$"
                    },
                    "uuid": {
                        "description": "Ignored. The server generates the UUID."
                    },
                    "createdAt": {
                        "description": "Ignored. The server sets the creation timestamp."
                    },
                    "availableFrom": {
                        "description": "Null uses the creation time.",
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    },
                    "availableTo": {
                        "description": "Null means the entry has no expiration.",
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    },
                    "password": {
                        "description": "Null removes the link password.",
                        "type": "string",
                        "writeOnly": true,
                        "nullable": true,
                        "maxLength": 255
                    },
                    "isSingleUse": {
                        "type": "boolean"
                    }
                },
                "type": "object",
                "additionalProperties": false
            },
            "UrlEntryFeatures": {
                "properties": {
                    "availableFrom": {
                        "description": "Null uses the creation time.",
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    },
                    "availableTo": {
                        "description": "Null means the entry has no expiration.",
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    },
                    "password": {
                        "description": "Null removes the link password.",
                        "type": "string",
                        "writeOnly": true,
                        "nullable": true,
                        "maxLength": 255
                    },
                    "isSingleUse": {
                        "type": "boolean"
                    }
                },
                "type": "object",
                "additionalProperties": false
            },
            "UrlEntryDestination": {
                "required": [
                    "url"
                ],
                "properties": {
                    "url": {
                        "type": "string",
                        "format": "uri",
                        "example": "https://example.com/products",
                        "maxLength": 2048
                    }
                },
                "type": "object",
                "additionalProperties": false
            },
            "UrlEntryStatistics": {
                "properties": {
                    "urlEntry": {
                        "$ref": "#/components/schemas/UrlEntry"
                    },
                    "totalVisits": {
                        "type": "integer"
                    },
                    "uniqueVisitors": {
                        "type": "integer"
                    },
                    "visitsByCountry": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "integer"
                        }
                    }
                },
                "type": "object"
            },
            "Error": {
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "string"
                    }
                },
                "type": "object"
            }
        },
        "responses": {
            "Unauthorized": {
                "description": "Missing, invalid, or expired company API key",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "NotFound": {
                "description": "URL entry is missing, belongs to another company, or is inactive or expired",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "BadRequest": {
                "description": "Malformed JSON or a body that is not a JSON object",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "InvalidPayload": {
                "description": "Invalid or unsupported fields",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "UriConflict": {
                "description": "The short URI is already in use",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            }
        },
        "securitySchemes": {
            "CompanyApiKey": {
                "type": "apiKey",
                "description": "Use the key issued for your company. Api-Key is also accepted by servers that drop headers containing underscores.",
                "name": "API_KEY",
                "in": "header"
            }
        }
    },
    "security": [
        {
            "CompanyApiKey": []
        }
    ]
}