This API method creates a new target. Free users can use up to two targets on the free geohost.

Request

POST /target/geohost_name/target_name?alias=alias_name&priority=priority_value&weight=weight_value&schedule=schedule_time&requiredchecks=reqChecks&enabled=enabled_status&check=check_name HTTP/1.0
Host: api.gslb.me 
Accept: encoding_type
Content-Length: 0
Authorization: Basic base64_credentials

Where:

  • geohost_name is the name of the geohost where you need to create the target
  • target_name is the name of the target to be created
  • alias_name is the (optional) alias IP or FQDN for the target to be created
  • priority_value is the target priority, only used if the geohost’s balancing algorithm is “priority”
  • weight_value is the target “weight”, only used if the geohosts’s balancing algorithm is “weighted”
  • schedule_time is the schedule interval in seconds to run all checks for the target
  • reqChecks is the minimum number of “healthy” checks needed to mark the target as “healthy”
  • enabled is the state of the target (must be set to either “true” or “false”)
  • check is the name (case sensitive) of an existing check to associate to the target. This field can be repeated several times, one for each check to associate to the target
  • base64_credentials is username:password in base64-encoded format (HTTP Basic Authentication)
  • encoding_type is either application/xml or application/json (if the “Accept” header is omitted, response will be JSON-encoded)

Note: The “Content-Length: 0” header is mandatory.

Sample requests:

  • Raw request:
POST /target/mygeohost.zone.com/11.22.33.44?alias=host-11.22.33.44-alias.zone.com&priority=123&weight=22&schedule=60&requiredchecks=2&enabled=true&check=CPU-check&check=ICMP-check HTTP/1.0
Host: api.gslb.me 
Accept: application/json
Content-Length: 0
Authorization: Basic dGVzdHVzZXJAZ3NsYi5tZTp0ZXN0cGFzc3dvcmQK
  • Using curl:
curl -u testuser@gslb.me:testpassword -X POST -H "Accept: application/json" https://api.gslb.me/target/mygeohost.zone.com/11.22.33.44?alias=host-11.22.33.44-alias.zone.com&priority=123&weight=22&schedule=60&requiredchecks=2&enabled=true&check=CPU-check&check=ICMP-check

Response

  • In case of success:
HTTP/1.1 200 OK
Content-Type: application/json

{"message":"Done","returncode":"0"}

  • If the user is not allowed to create more targets (free geohosts allow up to 2 targets)
HTTP/1.1 403 Forbidden
Content-Type: application/json

{"message":"No available paid geohosts, can't use more than 2 targets on a free geohost","returncode":"5"}

  • If the geohost does not exist
HTTP/1.1 404 Not Found
Content-Type: application/json

{"message":"Geohost not found","returncode":"2"}

  • If the target does not exist
HTTP/1.1 404 Not Found
Content-Type: application/json

{"message":"Target not found","returncode":"2"}

  • If the target already exists
HTTP/1.1 403 Forbidden
Content-Type: application/json

{"message":"Target already exists","returncode":"6"}

 

  • If the specified check does not exist
HTTP/1.1 404 Not Found
Content-Type: application/json

{"message":"Check \"My custom check\" not found","returncode":"2"}

  • If one or more parameters are invalid
HTTP/1.1 400 Bad Request
Content-Type: application/json

{"message":"Invalid parameters","returncode":"3"}
  • If one parameter has a value outside the allowed range
HTTP/1.1 400 Bad Request
Content-Type: application/json

{"message":"Invalid <parameter_name>, must be between <minimum> and <maximum>","returncode":"3"}

  • In case of internal error:
HTTP/1.1 500 Server Error
Content-Type: application/json

{"message":"Internal error, please contact support@gslb.me","returncode":"4"}