openapi: 3.0.0
info:
  title: Unkey API
  version: 1.0.0
servers:
  - url: https://api.unkey.dev
  - url: http://localhost
paths:
  /v0/events:
    post:
      operationId: v0.events.create
      summary: Create events
      description: Accept NDJSON payload of events and process them
      requestBody:
        content:
          application/x-ndjson:
            schema:
              $ref: '#/components/schemas/V0EventsRequestBody'
        required: true
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V0EventsResponseBody'
        '400':
          description: Bad request
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/BaseError'
          description: Error
      tags:
        - events
components:
  schemas:
    BaseError:
      properties:
        requestId:
          description: A unique id for this request. Please always provide this to support.
          example: req_123
          type: string
        detail:
          description: A human-readable explanation specific to this occurrence of the problem.
          example: Property foo is required but is missing.
          type: string
        instance:
          description: A URI reference that identifies the specific occurrence of the problem.
          example: https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          example: 400
          format: int
          type: integer
        title:
          description: A short, human-readable summary of the problem type. This value should not change between occurrences of the error.
          example: Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          example: https://example.com/errors/example
          format: uri
          type: string
      type: object
      required:
        - requestId
        - detail
        - instance
        - status
        - title
        - type
    ValidationError:
      additionalProperties: false
      properties:
        requestId:
          description: A unique id for this request. Please always provide this to support.
          example: req_123
          type: string
        detail:
          description: A human-readable explanation specific to this occurrence of the problem.
          example: Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ValidationErrorDetail'
          type:
            - array
        instance:
          description: A URI reference that identifies the specific occurrence of the problem.
          example: https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          example: 400
          format: int
          type: integer
        title:
          description: A short, human-readable summary of the problem type. This value should not change between occurrences of the error.
          example: Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          example: https://example.com/errors/example
          format: uri
          type: string
      type: object
      required:
        - requestId
        - detail
        - instance
        - status
        - title
        - type
        - errors
    ValidationErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        fix:
          description: A human-readable message describing how to fix the error.
          type: string
      type: object
      required:
        - message
        - location
    V0EventsResponseBody:
      type: object
      properties:
        $schema:
          description: A URL to the JSON Schema for this object.
          example: https://api.unkey.dev/schemas/V0EventsResponseBody.json
          format: uri
          readOnly: true
          type: string
        successful_rows:
          type: integer
          description: The number of rows that were successfully processed
        quarantined_rows:
          type: integer
          description: The number of rows that were quarantined
      required:
        - successful_rows
        - quarantined_rows
    V0EventsRequestBody:
      type: string
      description: NDJSON payload of events

---
To implement the `POST /v0/events` route in the `ExampleClient` class, we will create a new method called `createEvent`. This method will handle the serialization of the NDJSON payload, make the API call using the `fetch` method, and handle the response and potential errors.

### Steps:
1. **Define the method**: The method will be named `createEvent` and will accept a parameter for the NDJSON payload.
2. **Add route information**: Include a comment above the method indicating the route path, method, and tags.
3. **Handle request serialization**: The NDJSON payload will be passed as a string.
4. **Handle response serialization**: The response will be typed as `V0EventsResponseBody`.
5. **Error handling**: Handle both `ValidationError` and `BaseError` responses.
6. **Type definitions**: Ensure all types are correctly used from the `./components.ts` file.

Here is the code snippet to add to the `./client.ts` file:

```typescript:client.ts
  // POST /v0/events
  // Tags: events
  async createEvent(
    body: string
  ): Promise<V0EventsResponseBody> {
    try {
      const response = await this.fetch<V0EventsRequestBody>({
        method: 'POST',
        path: '/v0/events',
        body,
        headers: {
          'Content-Type': 'application/x-ndjson',
        },
      });

      if (!response.ok) {
        const errorData = await response.json();
        if (response.status === 400) {
          throw new ExampleError('Validation Error', {
            status: 400,
            data: errorData as ValidationError,
          });
        } else {
          throw new ExampleError('Server Error', {
            status: response.status,
            data: errorData as BaseError,
          });
        }
      }

      return (await response.json()) as V0EventsResponseBody;
    } catch (error) {
      throw new ExampleError('Network Error', { status: 500, data: error });
    }
  }

// Type definitions for the new method
export interface CreateEventResponse extends V0EventsResponseBody {}
```

This code snippet adds the `createEvent` method to the `ExampleClient` class, handling the creation of events via the specified API route. It includes error handling for both validation and server errors, ensuring that the method is fully typed and adheres to the requirements specified in the OpenAPI schema.