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.

live_help Notes

assignment This action requires one of theses roles: 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. Must be unique.

user[first_name] required . Must be String

The first name.

user[last_name] required . Must be String

The last name.

user[password] optional , nil allowed . Must be String

The password.

user[pool_year] optional , nil allowed . Must be String

The pool year.

user[pool_month] optional , nil allowed . 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[meta] optional , nil allowed . Must be String

The meta.

user[cursus_id] optional , nil allowed . Must be String

The cursus id.

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 String

The birth date.

user[user_candidature_attributes][gender] optional , nil allowed . Must be String

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][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 DateTime

The end at.

user[cursus_users_attributes][begin_at] required . Must be DateTime

The begin at.

user[cursus_users_attributes][_destroy] optional , nil allowed . Must be String

The destroy.

user[languages_user_attributes] optional , nil allowed . Must be an Array of nested elements

The languages user attributes.

user[languages_user_attributes][id] optional , nil allowed . Must be Fixnum

The id.

user[languages_user_attributes][language_id] required . Must be Fixnum

The language id.

user[languages_user_attributes][position] optional , nil allowed . Must be Fixnum

The position.

user[languages_user_attributes][_destroy] optional , nil allowed . Must be String

The destroy.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/users
{
  "user": {
    "campus_id": "1",
    "cursus_users_attributes": [
      {
        "begin_at": "2017-03-09 15:20:50 UTC",
        "cursus_id": "1",
        "end_at": "2017-07-06 15:19:52 UTC",
        "user_id": ""
      }
    ],
    "email": "wan.obi@caramail.net",
    "first_name": "Obi-Wan",
    "kind": "student",
    "languages_users_attributes": [
      {
        "language_id": "1",
        "position": "1",
        "user_id": ""
      }
    ],
    "last_name": "Kenobi",
    "password": "totoroTOTOROOO",
    "pool_month": "november",
    "pool_year": "2017",
    "status": "admis",
    "user_candidature_attributes": {
      "birth_city": "Taliabury",
      "birth_country": "China",
      "birth_date": "1994-04-18",
      "contact_affiliation": "friend",
      "contact_first_name": "Myrtis",
      "contact_last_name": "Schaden",
      "contact_phone1": "0695847362",
      "contact_phone2": "0491314200",
      "country": "New Caledonia",
      "gender": "female",
      "language": "",
      "max_level_logic": "2",
      "max_level_memory": "1",
      "meeting_date": "2017-01-14",
      "other_information": "3",
      "pin": "4242",
      "piscine_date": "2017-02-07",
      "postal_city": "South Adolftown",
      "postal_complement": "",
      "postal_country": "Uganda",
      "postal_street": "1918 Beer Valley",
      "postal_zip_code": "50021-3639",
      "user_id": "",
      "zip_code": "79013-4274"
    }
  }
}
201
{
  "id": 69,
  "login": "okenobi",
  "url": "https://api.intra.42.fr/v2/users/okenobi"
}
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-03-09 15:20:50 UTC","cursus_id":"1","end_at":"2017-07-06 15:19:52 UTC","user_id":""}],"email":"wan.obi@caramail.net","first_name":"Obi-Wan","kind":"student","languages_users_attributes":[{"language_id":"1","position":"1","user_id":""}],"last_name":"Kenobi","password":"totoroTOTOROOO","pool_month":"november","pool_year":"2017","status":"admis","user_candidature_attributes":{"birth_city":"Taliabury","birth_country":"China","birth_date":"1994-04-18","contact_affiliation":"friend","contact_first_name":"Myrtis","contact_last_name":"Schaden","contact_phone1":"0695847362","contact_phone2":"0491314200","country":"New Caledonia","gender":"female","language":"","max_level_logic":"2","max_level_memory":"1","meeting_date":"2017-01-14","other_information":"3","pin":"4242","piscine_date":"2017-02-07","postal_city":"South Adolftown","postal_complement":"","postal_country":"Uganda","postal_street":"1918 Beer Valley","postal_zip_code":"50021-3639","user_id":"","zip_code":"79013-4274"}}}' "https://api.intra.42.fr/v2/users"

{
  "id": 69,
  "login": "okenobi",
  "url": "https://api.intra.42.fr/v2/users/okenobi"
}
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-03-09 15:20:50 UTC", cursus_id: "1", end_at: "2017-07-06 15:19:52 UTC", user_id: ""}], email: "wan.obi@caramail.net", first_name: "Obi-Wan", kind: "student", languages_users_attributes: [{language_id: "1", position: "1", user_id: ""}], last_name: "Kenobi", password: "totoroTOTOROOO", pool_month: "november", pool_year: "2017", status: "admis", user_candidature_attributes: {birth_city: "Taliabury", birth_country: "China", birth_date: "1994-04-18", contact_affiliation: "friend", contact_first_name: "Myrtis", contact_last_name: "Schaden", contact_phone1: "0695847362", contact_phone2: "0491314200", country: "New Caledonia", gender: "female", language: "", max_level_logic: "2", max_level_memory: "1", meeting_date: "2017-01-14", other_information: "3", pin: "4242", piscine_date: "2017-02-07", postal_city: "South Adolftown", postal_complement: "", postal_country: "Uganda", postal_street: "1918 Beer Valley", postal_zip_code: "50021-3639", user_id: "", zip_code: "79013-4274"}}}
response = token.post("/v2/users", params: params)
response.status
# => 201
response.parsed
# => {"id"=>69, "login"=>"okenobi", "url"=>"https://api.intra.42.fr/v2/users/okenobi"}