Skip to content

Creates a new geofence​

PUT
/users/{userid}/geofences

Authorizations​

ApiKeyAuth

API Key for authentication. Retrieval from either API version login routes, or other authentication token type. See Authentication for more details.

Type
API Key (header: Authorization)
Example"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Parameters​

Path Parameters

userid*

User ID

Type
integer
Required

Request Body​

application/json
JSON
{
  
"center": {
  
  
"lat": 0,
  
  
"lng": 0
  
},
  
"foreignId": "string",
  
"listId": 0,
  
"meta": {
  
  
"additionalProperties": null
  
},
  
"name": "string",
  
"outline": [
  
  
{
  
  
  
"lat": 0,
  
  
  
"lng": 0
  
  
}
  
],
  
"radius": 0,
  
"type": "string"
}

Request example

Responses​

Created

application/json
JSON
{
  
"center": {
  
  
"lat": 0,
  
  
"lng": 0
  
},
  
"deviceId": 0,
  
"foreignId": "string",
  
"id": 0,
  
"list": {
  
  
"color": "string",
  
  
"id": 0,
  
  
"name": "string",
  
  
"ownerId": 0
  
},
  
"listId": 0,
  
"meta": {
  
  
"additionalProperties": null
  
},
  
"modified": true,
  
"name": "string",
  
"outline": [
  
  
{
  
  
  
"lat": 0,
  
  
  
"lng": 0
  
  
}
  
],
  
"ownerId": 0,
  
"radius": 0,
  
"type": "string"
}
Try this endpoint

Playground​

Authorization
Variables
Key
Value
Body

OpenAPI definition ​

References are expanded below, except recursive definitions and references with sibling fields. Documentation overrides are included. Full original OpenAPI spec (JSON).

View endpoint OpenAPI definition
yaml
info:
  title: Lightbug API
  version: '2'
externalDocs:
  description: ''
  url: ''
openapi: 3.1.0
servers:
  - url: https://api.lightbug.cloud/v2
security:
  - ApiKeyAuth: []
tags: []
paths:
  /users/{userid}/geofences:
    put:
      parameters:
        - description: User ID
          in: path
          name: userid
          required: true
          schema:
            type: integer
requestBody:
yaml
        content:
          application/json:
            schema:
              properties:
                center:
                  description: For circular geofences, the center {lat:x,lng:y}. Property is ignored if outline != null.
                  properties:
                    lat:
                      type: number
                    lng:
                      type: number
                  type: object
                foreignId:
                  type: string
                listId:
                  type: integer
                meta:
                  additionalProperties: {}
                  type: object
                name:
                  type: string
                outline:
                  description: |-
                    List of {lat:x,lng:y} objects representing the vertices of the polygon.
                    Not to be used with center and radius.
                  items:
                    description: For circular geofences, the center {lat:x,lng:y}. Property is ignored if outline != null.
                    properties:
                      lat:
                        type: number
                      lng:
                        type: number
                    type: object
                  type: array
                  uniqueItems: false
                radius:
                  description: For circular geofences, the radius of the circle in meters. Property is ignored if outline != null.
                  type: integer
                type:
                  type: string
              type: object
        description: Geofence to create
        required: true
yaml
      responses:
'201':
yaml
          content:
            application/json:
              schema:
                properties:
                  center:
                    description: For circular geofences, the center {lat:x,lng:y}. Property is ignored if outline != null.
                    properties:
                      lat:
                        type: number
                      lng:
                        type: number
                    type: object
                  deviceId:
                    type: integer
                  foreignId:
                    type: string
                  id:
                    type: integer
                  list:
                    properties:
                      color:
                        type: string
                      id:
                        type: integer
                      name:
                        type: string
                      ownerId:
                        type: integer
                    required:
                      - color
                      - name
                    type: object
                  listId:
                    type: integer
                  meta:
                    additionalProperties: {}
                    type: object
                  modified:
                    type: boolean
                  name:
                    type: string
                  outline:
                    description: |-
                      List of {lat:x,lng:y} objects representing the vertices of the polygon.
                      Not to be used with center and radius.
                    items:
                      description: For circular geofences, the center {lat:x,lng:y}. Property is ignored if outline != null.
                      properties:
                        lat:
                          type: number
                        lng:
                          type: number
                      type: object
                    type: array
                    uniqueItems: false
                  ownerId:
                    type: integer
                  radius:
                    description: For circular geofences, the radius of the circle in meters. Property is ignored if outline != null.
                    type: integer
                  type:
                    type: string
                type: object
          description: Created
'400':
yaml
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: 400
                    type: integer
                  message:
                    example: status bad request
                    type: string
                type: object
          description: Bad Request
'401':
yaml
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: 400
                    type: integer
                  message:
                    example: status bad request
                    type: string
                type: object
          description: Unauthorized
'500':
yaml
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: 400
                    type: integer
                  message:
                    example: status bad request
                    type: string
                type: object
          description: Internal Server Error
yaml
      security:
        - ApiKeyAuth: []
      summary: Creates a new geofence
      tags:
        - geofences
      operationId: put-users-userid-geofences
components:
  securitySchemes:
    ApiKeyAuth:
      in: header
      name: Authorization
      type: apiKey
      description: API Key for authentication. Retrieval from either API version login routes, or other authentication token type. See <a href='/apis/authentication'>Authentication</a> for more details.
      example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...