POST /v2/users
Create a user
This is the main call for user creation on the 42 ecosystem.
This call requires at least the email
, campus_id
, first_name
and last_name
fields. If the login isn’t specified, it will be generated from the supplied first_name
and the last_name
. If no cursus is supplied, the user will join the cursus piscine-c
by default.
If an endpoint is configured for the supplied campus, it will be triggered before save. You can read more about campus endpoints on the endpoint documentation.
This call also accept additional data, nested under user_candidature_attributes
, wich can be added later with the user candidature call and is only visible for the user and at least the basic_staff
role. The supplied email must be the personal email of the user. It will be moved to user_candidature after save, replacer by the given campus’s alias. Adding an image will generate an original, a medium and a small version of this one.
The meta
key allow a hash with ldap_group
. The ldap_group
has transmited to LDAP server if campus is
live_help Notes
Advanced tutor
settings Params
Param name | Description |
---|---|
user | optional , nil allowed . Must be a Hash |
user[login] |
optional
, nil allowed
. Must be String
The login. Default to . Must be unique. |
user[email] |
required
. Must be String
The email. Default to . Must be unique. |
user[first_name] |
required
. Must be String
The first name. |
user[last_name] |
required
. Must be String
The last name. |
user[usual_first_name] |
required
. Must be String
The usual first name. Maximum length is 42. |
user[password] |
optional
, nil allowed
. Must be String
The password. |
user[pool_year] |
required
. Must be String
The pool year. |
user[pool_month] |
required
. Must be String
The pool month. |
user[kind] |
required
. Must be one of: admin , student , external .
The kind. |
user[status] |
optional
, nil allowed
. Must be String
The status. |
user[image] |
optional
, nil allowed
. Must be File
The image. Allow blank length is true. Allow nil length is true. Minimum length is 3072. Maximum length is 1048576. |
user[campus_id] |
optional
, nil allowed
. Must be String
The campus id. |
user[cursus_id] |
optional
, nil allowed
. Must be String
The cursus id. |
user[email_stop] |
optional
, nil allowed
. Must be one of: true , false .
Is it email stop ? Default to false. |
user[skip_welcome_mail] |
optional
, nil allowed
. Must be String
The skip welcome mail. |
user[user_candidature_attributes] |
optional
, nil allowed
. Must be an Array of nested elements
The user candidature attributes. |
user[user_candidature_attributes][id] |
optional
, nil allowed
. Must be Fixnum
The id. |
user[user_candidature_attributes][user_id] |
optional
, nil allowed
. Must be Fixnum
The user id. |
user[user_candidature_attributes][birth_date] |
optional
, nil allowed
. Must be Fixnum
The birth date. Must be at least 13 years ago. must be at most 99 years ago. |
user[user_candidature_attributes][gender] |
optional
, nil allowed
. Must be one of: male , female , other .
The gender. |
user[user_candidature_attributes][zip_code] |
optional
, nil allowed
. Must be String
The zip code. |
user[user_candidature_attributes][country] |
optional
, nil allowed
. Must be String
The country. |
user[user_candidature_attributes][phone_country_code] |
optional
, nil allowed
. Must be one of: AD , AE , AF , AG , AI , AL , AM , AN , AO , AQ , AR , AS , AT , AU , AW , AX , AZ , BA , BB , BD , BE , BF , BG , BH , BI , BJ , BL , BM , BN , BO , BQ , BR , BS , BT , BV , BW , BY , BZ , CA , CC , CD , CF , CG , CH , CI , CK , CL , CM , CN , CO , CR , CU , CV , CW , CX , CY , CZ , DE , DJ , DK , DM , DO , DZ , EC , EE , EG , EH , ER , ES , ET , FI , FJ , FK , FM , FO , FR , GA , GB , GD , GE , GF , GG , GH , GI , GL , GM , GN , GP , GQ , GR , GS , GT , GU , GW , GY , HK , HM , HN , HR , HT , HU , ID , IE , IL , IM , IN , IO , IQ , IR , IS , IT , JE , JM , JO , JP , KE , KG , KH , KI , KM , KN , KP , KR , KW , KY , KZ , LA , LB , LC , LI , LK , LR , LS , LT , LU , LV , LY , MA , MC , MD , ME , MF , MG , MH , MK , ML , MM , MN , MO , MP , MQ , MR , MS , MT , MU , MV , MW , MX , MY , MZ , NA , NC , NE , NF , NG , NI , NL , NO , NP , NR , NU , NZ , OM , PA , PE , PF , PG , PH , PK , PL , PM , PN , PR , PS , PT , PW , PY , QA , RE , RO , RS , RU , RW , SA , SB , SC , SD , SE , SG , SH , SI , SJ , SK , SL , SM , SN , SO , SR , SS , ST , SV , SX , SY , SZ , TC , TD , TF , TG , TH , TJ , TK , TL , TM , TN , TO , TR , TT , TV , TW , TZ , UA , UG , UM , US , UY , UZ , VA , VC , VE , VG , VI , VN , VU , WF , WS , XK , YE , YT , ZA , ZM , ZW , .
The phone country code. |
user[user_candidature_attributes][birth_city] |
optional
, nil allowed
. Must be String
The birth city. |
user[user_candidature_attributes][birth_country] |
optional
, nil allowed
. Must be String
The birth country. |
user[user_candidature_attributes][postal_street] |
optional
, nil allowed
. Must be String
The postal street. |
user[user_candidature_attributes][postal_complement] |
optional
, nil allowed
. Must be String
The postal complement. |
user[user_candidature_attributes][postal_city] |
optional
, nil allowed
. Must be String
The postal city. |
user[user_candidature_attributes][postal_zip_code] |
optional
, nil allowed
. Must be String
The postal zip code. |
user[user_candidature_attributes][postal_country] |
optional
, nil allowed
. Must be String
The postal country. |
user[user_candidature_attributes][contact_affiliation] |
optional
, nil allowed
. Must be String
The contact affiliation. |
user[user_candidature_attributes][contact_last_name] |
optional
, nil allowed
. Must be String
The contact last name. |
user[user_candidature_attributes][contact_first_name] |
optional
, nil allowed
. Must be String
The contact first name. |
user[user_candidature_attributes][contact_phone1] |
optional
, nil allowed
. Must be String
The contact phone1. |
user[user_candidature_attributes][contact_phone2] |
optional
, nil allowed
. Must be String
The contact phone2. |
user[user_candidature_attributes][max_level_memory] |
optional
, nil allowed
. Must be Fixnum
The max level memory. |
user[user_candidature_attributes][max_level_logic] |
optional
, nil allowed
. Must be Fixnum
The max level logic. |
user[user_candidature_attributes][other_information] |
optional
, nil allowed
. Must be String
The other information. |
user[user_candidature_attributes][language] |
optional
, nil allowed
. Must be String
The language. |
user[user_candidature_attributes][meeting_date] |
optional
, nil allowed
. Must be DateTime
The meeting date. |
user[user_candidature_attributes][piscine_date] |
optional
, nil allowed
. Must be String
The piscine date. |
user[user_candidature_attributes][email] |
optional
, nil allowed
. Must be String
The email. |
user[user_candidature_attributes][pin] |
optional
, nil allowed
. Must be String
The pin. |
user[user_candidature_attributes][phone] |
optional
, nil allowed
. Must be String
The phone. |
user[cursus_users_attributes] |
optional
, nil allowed
. Must be an Array of nested elements
The cursus users attributes. |
user[cursus_users_attributes][id] |
optional
, nil allowed
. Must be Fixnum
The id. |
user[cursus_users_attributes][cursus_id] |
required
. Must be Fixnum
The cursus id. Must be unique in the scope of a given user. |
user[cursus_users_attributes][end_at] |
optional
, nil allowed
. Must be Fixnum
The end at… . |
user[cursus_users_attributes][begin_at] |
required
. Must be Fixnum
The begin at… |
user[cursus_users_attributes][_destroy] |
optional
, nil allowed
. Must be String
The destroy. |
user[languages_users_attributes] |
optional
, nil allowed
. Must be an Array of nested elements
The languages users attributes. |
user[languages_users_attributes][id] |
optional
, nil allowed
. Must be Fixnum
The id. |
user[languages_users_attributes][language_id] |
required
. Must be Fixnum
The language id. |
user[languages_users_attributes][position] |
optional
, nil allowed
. Must be Fixnum
The position. |
user[languages_users_attributes][_destroy] |
optional
, nil allowed
. Must be String
The destroy. |
Examples
POST /v2/users
{
"user": {
"campus_id": "1",
"cursus_users_attributes": [
{
"begin_at": "2017-11-25 13:44:19 UTC",
"cursus_id": "1",
"end_at": "2018-03-22 13:43:10 UTC",
"user_id": ""
}
],
"email": "[email protected]",
"first_name": "Anakin",
"kind": "student",
"languages_users_attributes": [
{
"language_id": "1",
"position": "1",
"user_id": ""
}
],
"last_name": "Skywalker",
"password": "totoroTOTOROOO",
"pool_month": "may",
"pool_year": "2017",
"status": "admis",
"user_candidature_attributes": {
"birth_city": "East Adrainshire",
"birth_country": "Iran",
"birth_date": "1998-06-08",
"contact_affiliation": "parent",
"contact_first_name": "Dewayne",
"contact_last_name": "Nader",
"contact_phone1": "0695847362",
"contact_phone2": "0491314200",
"country": "Turks and Caicos Islands",
"gender": "female",
"language": "",
"max_level_logic": "2",
"max_level_memory": "1",
"meeting_date": "2017-10-05",
"other_information": "3",
"pin": "4242",
"piscine_date": "2017-11-15",
"postal_city": "Emelyborough",
"postal_complement": "",
"postal_country": "Lesotho",
"postal_street": "621 Tromp Lakes",
"postal_zip_code": "10047",
"user_id": "",
"zip_code": "89457-3613"
}
}
}
201
{
"id": 127,
"login": "anakisky",
"url": "https://api.intra.42.fr/v2/users/anakisky"
}
curl -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"user":{"campus_id":"1","cursus_users_attributes":[{"begin_at":"2017-11-25 13:44:19 UTC","cursus_id":"1","end_at":"2018-03-22 13:43:10 UTC","user_id":""}],"email":"[email protected]","first_name":"Anakin","kind":"student","languages_users_attributes":[{"language_id":"1","position":"1","user_id":""}],"last_name":"Skywalker","password":"totoroTOTOROOO","pool_month":"may","pool_year":"2017","status":"admis","user_candidature_attributes":{"birth_city":"East Adrainshire","birth_country":"Iran","birth_date":"1998-06-08","contact_affiliation":"parent","contact_first_name":"Dewayne","contact_last_name":"Nader","contact_phone1":"0695847362","contact_phone2":"0491314200","country":"Turks and Caicos Islands","gender":"female","language":"","max_level_logic":"2","max_level_memory":"1","meeting_date":"2017-10-05","other_information":"3","pin":"4242","piscine_date":"2017-11-15","postal_city":"Emelyborough","postal_complement":"","postal_country":"Lesotho","postal_street":"621 Tromp Lakes","postal_zip_code":"10047","user_id":"","zip_code":"89457-3613"}}}' "https://api.intra.42.fr/v2/users"
{
"id": 127,
"login": "anakisky",
"url": "https://api.intra.42.fr/v2/users/anakisky"
}
require "oauth2"
UID = "Your application uid"
SECRET = "Your application secret"
client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
token = client.client_credentials.get_token
params = {user: {campus_id: "1", cursus_users_attributes: [{begin_at: "2017-11-25 13:44:19 UTC", cursus_id: "1", end_at: "2018-03-22 13:43:10 UTC", user_id: ""}], email: "[email protected]", first_name: "Anakin", kind: "student", languages_users_attributes: [{language_id: "1", position: "1", user_id: ""}], last_name: "Skywalker", password: "totoroTOTOROOO", pool_month: "may", pool_year: "2017", status: "admis", user_candidature_attributes: {birth_city: "East Adrainshire", birth_country: "Iran", birth_date: "1998-06-08", contact_affiliation: "parent", contact_first_name: "Dewayne", contact_last_name: "Nader", contact_phone1: "0695847362", contact_phone2: "0491314200", country: "Turks and Caicos Islands", gender: "female", language: "", max_level_logic: "2", max_level_memory: "1", meeting_date: "2017-10-05", other_information: "3", pin: "4242", piscine_date: "2017-11-15", postal_city: "Emelyborough", postal_complement: "", postal_country: "Lesotho", postal_street: "621 Tromp Lakes", postal_zip_code: "10047", user_id: "", zip_code: "89457-3613"}}}
response = token.post("/v2/users", params: params)
response.status
# => 201
response.parsed
# => {"id"=>127, "login"=>"anakisky", "url"=>"https://api.intra.42.fr/v2/users/anakisky"}