---
title: "Create Farm"
method: POST
path: "/farms"
tags: ["Farms"]
---

# Create Farm

`POST /farms`

## Request

- Base URL: `https://api.purplegrain.com/api/v1`
- URL: `https://api.purplegrain.com/api/v1/farms`
- Auth: HTTP bearer

A name makes a property. It belongs to the business named by the
`organization` relationship, or — with no `organization` — to the
signed-in user's personal account (the `user` relationship may name
them explicitly). `centroid_lat` / `centroid_lon` give a property with
no outline yet a point for the map to open on — send both or neither.

`boundary`, `area_ha` and `area_source` are not accepted here: write the
outline with `updateFarmBoundary`, which measures the area. Requires
edit rights on the owner: a business's edit roles, or the person.
Assistants and API keys cannot set `visibility` to `link` or `public`
(403, nothing written). `private`, or leaving it unset, is allowed.

## Query parameters

- `include` string

## Request body

- FarmCreateModelAttributes: Flat attributes-adapter request body (Content-Type application/json). Attribute fields and relationships live directly under `data` (no nested `attributes` / `relationships` envelopes). Each relationship is a resource identifier object ({ id, type }). Equivalent JSON:API (nested) shape: `FarmCreateModel` sent as application/vnd.api+json.
  - `data` object, required
    - `visibility` 'private' | 'link' | 'public': Who can see the property and, through it, its paddocks, mobs and scoped task lists. `private` (default) is members only; `link` is anyone with the share token (`?share=`); `public` is anyone and search engines.
    - `name` string, required
    - `location` string, nullable
    - `size` string, nullable
    - `place_label` string, nullable: The geocoded label shown under the property name on the map. Distinct from `location` (the settings "Town, State" caption).
    - `centroid_lat` number, nullable: Latitude of the point the map opens on. Send both `centroid_lat` and `centroid_lon`, or neither — a half pair is rejected. A property with no boundary still needs a point ("Nothing on the map yet").
    - `centroid_lon` number, nullable: Longitude of the point the map opens on. Send both `centroid_lat` and `centroid_lon`, or neither.
    - `organization` object, nullable: The business the property belongs to. Omit it, or send null, for the signed-in user's personal account.
      - `id` string, nullable
      - `type` 'organization', nullable
    - `user` object, nullable: The person the property belongs to — only the signed-in user themselves.
      - `id` string, nullable
      - `type` 'user', nullable

## Response `201`

Created

- FarmsShowResponseAttributes
  - `data` FarmModelAttributes: Single farm in attributes-adapter shape (Accept application/json).
    - `id` string
    - `type` string
    - `slug` string: Unique within its parent (a property per owner; a paddock or mob per property); generated from the name and renamed with it. The old slug keeps resolving. See `resolveLink`.
    - `visibility` 'private' | 'link' | 'public': Who can see the property and, through it, its paddocks, mobs and scoped task lists. `private` (default) is members only; `link` is anyone with the share token (`?share=`); `public` is anyone and search engines.
    - `web_path` string: The property's address on the web, e.g. `/organizations/hillcrest/properties/yarrabee`. Present on a property read directly.
    - `url` string: The whole link to hand someone; for a property shared by link it carries `?share=<token>`. Present on a property read directly.
    - `can_edit` boolean: Whether the caller may change the property. From the session's role, never the address. Present on a property read directly.
    - `share_token` string, nullable: The token behind `visibility=link`. Returned only to callers who can change who sees the property.
    - `name` string
    - `location` string, nullable
    - `size` string, nullable
    - `place_label` string, nullable: The geocoded label shown under the property name on the map, e.g. "1180 Kywong Road, Currawarna NSW 2650".
    - `centroid_lat` number, nullable: Latitude of the point the map opens on. Present exactly when `centroid_lon` is.
    - `centroid_lon` number, nullable: Longitude of the point the map opens on. Present exactly when `centroid_lat` is.
    - `boundary` array[], nullable: The property outline: an array of rings, each ring an array of `[longitude, latitude]` pairs in RFC 7946 order — **longitude first** — with at least 4 positions and the first repeated last. Not a GeoJSON object (see `FarmBoundaryModel`).
      - array[]: One closed exterior ring.
        - number[]: [longitude, latitude]
    - `boundary_captured_at` string, date-time, nullable: When the boundary was last saved. Null while the property has no ring.
    - `boundary_source` 'traced' | 'grid' | 'gps' | 'imported', nullable: How the ring was captured — traced over imagery, placed on the grid with no imagery, walked with the phone's GPS, or read from a KML/shapefile. Null for a ring saved before provenance was recorded or by a caller that named no source. Written with the ring and cleared with it.
    - `boundary_captured_by` string, nullable: Id of the user who saved the ring, stamped server-side from the request's actor and never accepted from a client. Null when a machine token saved it, and null while the property has no ring.
    - `area_ha` number, nullable: Property area in hectares. Measured from the boundary when `area_source` is `drawn`; the farmer's own number when it is `typed`.
    - `area_source` 'typed' | 'drawn', nullable: Where `area_ha` came from. A `typed` area is never overwritten by a drawn one.
    - `paddock_count` integer: How many LIVE paddocks the property has. Archived paddocks are not counted.
    - `mob_count` integer: How many LIVE mobs the property has. Archived mobs are not counted.
    - `blocks` PropertyBlock[]: The property's live blocks. Empty when every paddock is in the home block.
      - `id` string, uuid
      - `name` string
      - `kind` 'outblock' | 'irrigation_farm' | 'management'
      - `block_number` string, nullable: An optional number the business uses for the block, such as "Farm 89".
      - `paddock_ids` string[]: The ids of the live paddocks in the block, ordered by paddock name. Each of those paddocks has this block's id as its `block_id`.
      - `area_ha` number, nullable: The sum of the member paddocks' areas, in hectares. Null when no member has an area.
      - `hull` object, nullable: The convex hull of the member paddocks' boundaries as a GeoJSON geometry (usually a Polygon) in [lng, lat]. Null when no member has a boundary. For the map's dashed outline; not a boundary of its own.
        - `type` string
        - `coordinates` unknown[]
          - unknown
    - `created_at` string, date-time
    - `updated_at` string, date-time
    - `organization` object: Present when include=organization
    - `user` object, nullable: The person who owns a personal property (linkage only); null on a business's farm.
  - `meta` PaginationMeta
    - `current_page` number
    - `next_page` number, nullable
    - `prev_page` number, nullable

## Other responses

- `401`: Unauthorized
- `403`: Forbidden
- `422`: Unprocessable Entity

---

[API](https://skmtc.dev/purplegrain/apis/purple-grain-api.md) · [All operations](https://skmtc.dev/purplegrain/apis/purple-grain-api/llms.txt) · [OpenAPI document](https://skmtc.dev/purplegrain/apis/purple-grain-api/revisions/4bedbc1c784c?raw)
