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

# Retrieve DKIM Keys

> Search for DKIM keys by domain, with optional filters.
If selector is provided, at most one key will be returned.




## OpenAPI

````yaml /email-api/api-reference/openapi.yaml get /domains/{domain}/dkim-keys
openapi: 3.0.0
info:
  contact:
    email: support@mailchannels.com
    name: MailChannels Corporation
  description: >
    This is the API reference for Email API. Here, you'll find more detailed
    information on every endpoint, including parameters, response formats, and
    error codes.
  title: Email API
  version: 1.4.0
servers:
  - url: https://api.mailchannels.net/tx/v1
security: []
tags:
  - name: Send
  - name: DKIM
  - name: Metrics
  - name: Sub-accounts
  - name: Suppression
  - name: Webhooks
  - name: Usage
  - name: Custom Tracking
paths:
  /domains/{domain}/dkim-keys:
    get:
      tags:
        - DKIM
      summary: Retrieve DKIM Keys
      description: |
        Search for DKIM keys by domain, with optional filters.
        If selector is provided, at most one key will be returned.
      parameters:
        - in: path
          name: domain
          required: true
          schema:
            type: string
        - in: query
          name: selector
          required: false
          schema:
            maxLength: 63
            minLength: 1
            type: string
        - in: query
          name: status
          required: false
          schema:
            enum:
              - active
              - retired
              - revoked
              - rotated
            type: string
        - description: |
            Number of keys to skip before returning results.
            The default is 0.
          in: query
          name: offset
          required: false
          schema:
            default: 0
            minimum: 0
            type: integer
        - description: |
            Maximum number of keys to return.
            The default is 10.
          in: query
          name: limit
          required: false
          schema:
            default: 10
            maximum: 100
            minimum: 1
            type: integer
        - description: >
            If true, includes the suggested DKIM DNS record for each returned
            key.

            Defaults to false.
          in: query
          name: include_dns_record
          required: false
          schema:
            default: false
            type: boolean
        - in: header
          name: X-Api-Key
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DKIMKeyList'
          description: Successfully retrieved DKIM keys
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '500':
          description: Internal Server Error
      x-codeSamples:
        - label: Node.js
          lang: javascript
          source: >-
            import { MailChannels } from "mailchannels-sdk";


            const { MAILCHANNELS_API_KEY, DOMAIN } = process.env;

            if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY
            before running");

            if (!DOMAIN) throw new Error("Set DOMAIN (the sending domain, e.g.
            example.com)");


            const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);


            const { data, error } = await
            mailchannels.domains.dkim.list(DOMAIN);


            if (error) {
              console.error("List DKIM keys failed:", error);
              process.exit(1);
            }

            console.log(data);
        - label: Python
          lang: python
          source: |-
            import os
            import sys

            import mailchannels

            if not os.environ.get("MAILCHANNELS_API_KEY"):
                sys.exit("Set MAILCHANNELS_API_KEY before running")

            domain = os.environ.get("DOMAIN")
            if not domain:
                sys.exit("Set DOMAIN (the sending domain, e.g. example.com)")

            # List all MailChannels-managed DKIM keys for the domain.
            response = mailchannels.Dkim.list(domain)

            print(response)
        - label: PHP
          lang: php
          source: >-
            <?php


            require_once __DIR__ . '/vendor/autoload.php';


            use MailChannels\Client;


            $api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error:
            MAILCHANNELS_API_KEY is not set\n");

            $domain  = getenv('DOMAIN') or exit("Error: DOMAIN is not set\n");


            $client = new Client(apiKey: $api_key);


            $response = $client->dkim->list($domain);


            print_r($response->toArray());
components:
  schemas:
    DKIMKeyList:
      properties:
        keys:
          description: |
            List of keys matching the filter.
            Empty if no keys match the filter.
          items:
            $ref: '#/components/schemas/DKIMKeyInfo'
          type: array
      required:
        - keys
      type: object
    ErrorResponse:
      properties:
        errors:
          description: >
            This is an array error objects that provide machine and human
            readable descriptions of the errors.
          items:
            type: string
          type: array
      type: object
    DKIMKeyInfo:
      properties:
        algorithm:
          description: |
            Algorithm used for the key pair
          type: string
        created_at:
          description: |
            Timestamp when the key pair was created
          format: date-time
          nullable: true
          type: string
        dkim_dns_records:
          description: |
            Suggested DNS records for the DKIM key
          items:
            $ref: '#/components/schemas/DKIMDnsRecord'
          type: array
        domain:
          description: |
            Domain associated with the key pair
          type: string
        gracePeriodExpiresAt:
          description: >
            UTC timestamp after which you can no longer use the rotated key for
            signing
          format: date-time
          nullable: true
          type: string
        key_length:
          description: |
            Key length in bits
          type: integer
        public_key:
          type: string
        retiresAt:
          description: |
            UTC timestamp when a rotated key pair is retired
          format: date-time
          nullable: true
          type: string
        selector:
          description: |
            Selector assigned to the key pair
          type: string
        status:
          enum:
            - active
            - retired
            - revoked
            - rotated
          type: string
        status_modified_at:
          description: |
            Timestamp when the key was last modified
          format: date-time
          nullable: true
          type: string
      required:
        - domain
        - selector
        - public_key
        - status
        - algorithm
      type: object
    DKIMDnsRecord:
      description: |
        Suggested DNS record for the DKIM key
      nullable: true
      properties:
        name:
          type: string
        type:
          example: TXT
          type: string
        value:
          type: string
      required:
        - name
        - type
        - value
      type: object

````