ユーザーの作成

このコード・スニペットでは、ユーザを作成する方法を学びます。

以下の変数が、便利な方法で必要な値に設定されていることを確認してください:

キー説明
USER_NAME

The unique name of the User.

USER_DISPLAY_NAME

The display name of the User.

Prerequisites

You will need to use an existing Application in order to be able to create a User. See the Create Conversation code snippet for information on how to create an Application.

Write the code

Add the following to create-user.sh:

curl -X "POST" "https://api.nexmo.com/v1/users" \
     -H 'Authorization: Bearer '$JWT\
     -H 'Content-Type: application/json' \
     -d $'{
  "name": "'$USER_NAME'",
  "display_name": "'$USER_DISPLAY_NAME'"
}'

View full source

Run your code

Save this file to your machine and run it:

bash create-user.sh

試してみる

コードを実行すると、新しいユーザが作成されます。