> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexprice.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Search emails

> Use when reviewing emails sent to customers, for example every bounced email this month or every email to one customer. Filter by delivery status, trigger, customer, document and date. Newest first; paginated.



## OpenAPI

````yaml https://swagger.flexprice.io post /emails/search
openapi: 3.0.1
info:
  title: Flexprice API
  description: Flexprice API Service
  contact:
    name: API Support
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
  version: '1.0'
servers:
  - url: https://us.api.flexprice.io/v1
    description: US Region
  - url: https://api.cloud.flexprice.io/v1
    description: India Region
  - url: https://canada.api.flexprice.io/v1
    description: Canada Region
  - url: https://eu.api.flexprice.io/v1
    description: EU Region
security: []
paths:
  /emails/search:
    post:
      tags:
        - Invoices
      summary: Search emails
      description: >-
        Use when reviewing emails sent to customers, for example every bounced
        email this month or every email to one customer. Filter by delivery
        status, trigger, customer, document and date. Newest first; paginated.
      operationId: queryEmail
      requestBody:
        description: Filter
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/types.EmailLogFilter'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListEmailLogsResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: typescript
          label: TypeScript
          source: |-
            import { Flexprice } from "@flexprice/sdk";

            const flexprice = new Flexprice({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await flexprice.invoices.queryEmail({});

              console.log(result);
            }

            run();
        - lang: go
          label: Go
          source: "package main\n\nimport(\n\t\"context\"\n\tflexprice \"github.com/flexprice/go-sdk/v2\"\n\t\"github.com/flexprice/go-sdk/v2/models/types\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := flexprice.New(\n        flexprice.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n    )\n\n    res, err := s.Invoices.QueryEmail(ctx, types.EmailLogFilter{})\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.ListEmailLogsResponse != nil {\n        // handle response\n    }\n}"
        - lang: python
          label: Python
          source: |-
            from flexprice import Flexprice


            with Flexprice(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as f_client:

                res = f_client.invoices.query_email()

                # Handle response
                print(res)
components:
  schemas:
    types.EmailLogFilter:
      type: object
      properties:
        customer_ids:
          type: array
          items:
            type: string
        delivery_statuses:
          type: array
          items:
            $ref: '#/components/schemas/types.EmailDeliveryStatus'
        end_time:
          type: string
          format: date-time
        entity_ids:
          type: array
          items:
            type: string
        entity_type:
          $ref: '#/components/schemas/types.SystemEntityType'
        expand:
          type: string
        limit:
          maximum: 1000
          minimum: 1
          type: integer
        offset:
          minimum: 0
          type: integer
        order:
          type: string
          enum:
            - asc
            - desc
        sort:
          type: string
        start_time:
          type: string
          format: date-time
        status:
          $ref: '#/components/schemas/types.Status'
        triggers:
          type: array
          items:
            $ref: '#/components/schemas/types.EmailTrigger'
      x-speakeasy-name-override: EmailLogFilter
    ListEmailLogsResponse:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/EmailLogResponse'
        pagination:
          $ref: '#/components/schemas/types.PaginationResponse'
    errors.ErrorResponse:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/errors.ErrorCode'
        http_status_code:
          type: integer
        message:
          type: string
      x-speakeasy-name-override: ErrorResponse
    types.EmailDeliveryStatus:
      type: string
      enum:
        - queued
        - sent
        - delivery_delayed
        - delivered
        - bounced
        - complained
        - failed
        - suppressed
        - skipped
      x-enum-varnames:
        - EmailDeliveryStatusQueued
        - EmailDeliveryStatusSent
        - EmailDeliveryStatusDeliveryDelayed
        - EmailDeliveryStatusDelivered
        - EmailDeliveryStatusBounced
        - EmailDeliveryStatusComplained
        - EmailDeliveryStatusFailed
        - EmailDeliveryStatusSuppressed
        - EmailDeliveryStatusSkipped
      x-speakeasy-name-override: EmailDeliveryStatus
    types.SystemEntityType:
      type: string
      enum:
        - feature
        - customer
        - plan
        - subscription
        - invoice
        - payment
        - credit_note
        - refund
        - wallet
        - entitlement
        - checkout_session
        - payment_method
        - price
        - event
        - commitment
        - billing_term
        - billing_instalment
      x-enum-varnames:
        - SystemEntityTypeFeature
        - SystemEntityTypeCustomer
        - SystemEntityTypePlan
        - SystemEntityTypeSubscription
        - SystemEntityTypeInvoice
        - SystemEntityTypePayment
        - SystemEntityTypeCreditNote
        - SystemEntityTypeRefund
        - SystemEntityTypeWallet
        - SystemEntityTypeEntitlement
        - SystemEntityTypeCheckoutSession
        - SystemEntityTypePaymentMethod
        - SystemEntityTypePrice
        - SystemEntityTypeEvent
        - SystemEntityTypeCommitment
        - SystemEntityTypeBillingTerm
        - SystemEntityTypeBillingInstalment
      x-speakeasy-name-override: SystemEntityType
    types.Status:
      type: string
      enum:
        - published
        - deleted
        - archived
      x-enum-varnames:
        - StatusPublished
        - StatusDeleted
        - StatusArchived
      x-speakeasy-name-override: Status
      x-speakeasy-unknown-values: allow
    types.EmailTrigger:
      type: string
      enum:
        - auto
        - manual
      x-enum-varnames:
        - EmailTriggerAuto
        - EmailTriggerManual
      x-speakeasy-name-override: EmailTrigger
    EmailLogResponse:
      type: object
      properties:
        cc_addresses:
          type: array
          items:
            type: string
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        customer_id:
          type: string
        delivered_at:
          type: string
          format: date-time
        delivery_status:
          $ref: '#/components/schemas/types.EmailDeliveryStatus'
        entity_id:
          type: string
        entity_type:
          $ref: '#/components/schemas/types.SystemEntityType'
        environment_id:
          type: string
        from_address:
          type: string
        id:
          type: string
        idempotency_key:
          type: string
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        provider:
          $ref: '#/components/schemas/types.EmailProvider'
        provider_message_id:
          type: string
        reply_to:
          type: string
        sent_at:
          type: string
          format: date-time
        status:
          $ref: '#/components/schemas/types.Status'
        status_reason:
          type: string
        subject:
          type: string
        template_key:
          $ref: '#/components/schemas/types.EmailTemplateKey'
        tenant_id:
          type: string
        to_addresses:
          type: array
          items:
            type: string
        trigger:
          $ref: '#/components/schemas/types.EmailTrigger'
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.PaginationResponse:
      type: object
      properties:
        limit:
          type: integer
        offset:
          type: integer
        total:
          type: integer
      x-speakeasy-name-override: PaginationResponse
    errors.ErrorCode:
      type: string
      enum:
        - http_client_error
        - system_error
        - internal_error
        - not_found
        - already_exists
        - version_conflict
        - validation_error
        - invalid_operation
        - permission_denied
        - database_error
        - service_unavailable
        - too_many_requests
        - not_implemented
      x-enum-varnames:
        - ErrCodeHTTPClient
        - ErrCodeSystemError
        - ErrCodeInternalError
        - ErrCodeNotFound
        - ErrCodeAlreadyExists
        - ErrCodeVersionConflict
        - ErrCodeValidation
        - ErrCodeInvalidOperation
        - ErrCodePermissionDenied
        - ErrCodeDatabase
        - ErrCodeServiceUnavailable
        - ErrCodeTooManyRequests
        - ErrCodeNotImplemented
      x-speakeasy-name-override: ErrorCode
    types.Metadata:
      type: object
      additionalProperties:
        type: string
      x-speakeasy-name-override: Metadata
    types.EmailProvider:
      type: string
      enum:
        - resend
        - local
      x-enum-varnames:
        - EmailProviderResend
        - EmailProviderLocal
      x-speakeasy-name-override: EmailProvider
    types.EmailTemplateKey:
      type: string
      enum:
        - invoice_finalized
      x-enum-varnames:
        - EmailTemplateInvoiceFinalized
      x-speakeasy-name-override: EmailTemplateKey
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: Enter your API key in the format *x-api-key &lt;api-key&gt;**
      name: x-api-key
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.