/users

Create a new user

Add External Ids

To add external ids to a user record just add the following to the request body. External ID represents a unique identifier for a user in an external system. The name of this external system is stored as integration_name. The combination of external_id and integration_name will always be unique.

{
  "email":"acme@example.com",
  "first_name":"John",
  "last_name":"Doe",
  # other attributes for a user
  ...
  ...
  ...
  # add external id for user
  "external_ids_attributes":[
    {
      "external_id":"987",
      "integration_name":"generic_tms"
    }
  ]
}
require 'uri'
require 'net/http'
require 'json'

url = URI('https://api.keeptruckin.com/v1/users')

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request['Authorization'] = "Bearer <OAUTH_TOKEN>"
request['Content-Type'] = 'application/json'
params = {
    :email                        => nil,
    :first_name                   => "John",
    :last_name                    => "Doe",
    :phone                        => nil,
    :phone_ext                    => nil,
    :time_zone                    => nil,
    :carrier_name                 => nil,
    :carrier_street               => nil,
    :carrier_city                 => nil,
    :carrier_state                => nil,
    :carrier_zip                  => nil,
    :violation_alerts             => "1_hour",
    :terminal_street              => nil,
    :terminal_city                => nil,
    :terminal_state               => nil,
    :terminal_zip                 => nil,
    :exception_24_hour_restart    => false,
    :exception_8_hour_break       => false,
    :exception_wait_time          => false,
    :exception_short_haul         => false,
    :exception_ca_farm_school_bus => false,
    :exception_adverse_driving    => false,
    :export_combined              => true,
    :export_recap                 => true,
    :export_odometers             => true,
    :metric_units                 => false,
    :username                     => "john.doe.demo.fleet",
    :password                     => "password",
    :cycle                        => nil,
    :driver_company_id            => nil,
    :minute_logs                  => false,
    :duty_status                  => "off_duty",
    :eld_mode                     => "none",
    :drivers_license_number       => nil,
    :drivers_license_state        => nil,
    :yard_moves_enabled           => false,
    :personal_conveyance_enabled  => false,
    :manual_driving_enabled       => false,
    :role                         => "driver",
    :status                       => "active",
    :dot_id                       => "12345678"
}
request.body = params.to_json

response = http.request(request)
puts response.read_body
Language
Authorization
Header
Click Try It! to start a request and see the response here!