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

# Register a farmer



## OpenAPI

````yaml /api-reference/openapi.json post /farmers/register
openapi: 3.1.0
info:
  title: MicroCrop Partner API
  version: 1.0.0
  description: >-
    Parametric crop & livestock insurance API for integrating partners. All
    requests authenticate with an organization API key in the `x-api-key`
    header.
servers:
  - url: https://app.microcrop.app/api
    description: Production (Base mainnet)
security:
  - apiKey: []
tags:
  - name: Farmers
  - name: Plots
  - name: Herds
  - name: Policies
  - name: Payments
  - name: Payouts
  - name: Organization
  - name: Determinations
paths:
  /farmers/register:
    post:
      tags:
        - Farmers
      summary: Register a farmer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FarmerRegister'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FarmerEnvelope'
        '400':
          $ref: '#/components/responses/BadRequest'
        '409':
          $ref: '#/components/responses/Conflict'
components:
  schemas:
    FarmerRegister:
      type: object
      required:
        - phoneNumber
        - nationalId
        - firstName
        - lastName
        - county
        - subCounty
      properties:
        phoneNumber:
          type: string
          pattern: ^\+254\d{9}$
          example: '+254712345678'
        nationalId:
          type: string
          minLength: 6
          maxLength: 20
        firstName:
          type: string
        lastName:
          type: string
        county:
          type: string
        subCounty:
          type: string
        ward:
          type: string
        village:
          type: string
    FarmerEnvelope:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/Farmer'
    Farmer:
      type: object
      properties:
        id:
          type: string
          format: uuid
        firstName:
          type: string
        lastName:
          type: string
        phoneNumber:
          type: string
        nationalId:
          type: string
        county:
          type: string
        subCounty:
          type: string
        kycStatus:
          type: string
          enum:
            - PENDING
            - APPROVED
            - REJECTED
    Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
              example: INVALID_INPUT
            message:
              type: string
            details: {}
  responses:
    BadRequest:
      description: Validation or business-rule error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Conflict:
      description: Duplicate resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key

````