Loading...

POST   https://api.3seventy.com/api/v2.1/account/{accountId}/api-key

Description

Create a new Api Key.

Path Parameters

accountId integer The Account to create an Api Key for. required

Request Properties application/json

Label string User defined identificator required
Type number Api Key type: 1 for a Common key, 2 for a Temporary key required
ValidTo string A date and time this key will be valid to. (Applicable for Temporary keys only) optional
{
     "Label": "Master",
     "Type": 1,
     "ValidTo": null
}

Response Properties application/json

AccountId integer An account this api key has access to.
Key string A key. Used as a login name.
Label string User-defined identificator
LastActivity string A time of last login.
Secret string A secret. Used as a login password.
Type string A key type mapping.
TypeId number Type of a key.
UserName string A user this key is owned by if any. For master keys only.
ValidTo string A datetime this key is valid to. For temporary keys only.
 {
    "Id": 1961,
    "Label": "Master",
    "Key": "022ff62714384e3693e709da772f8470",
    "TypeId": 1,
    "Type": 1,
    "ValidTo": null,
    "LastActivity": "2018-06-21T13:43:15",
    "AccountId": 43510,
    "UserName": "Integraton_User_1"
  }

C#


using System;
using System.Collections.Generic;
using System.Linq;
using ThreeSeventy.Vector.Client;
using ThreeSeventy.Vector.Client.Models;

public class Program
{

private static void Main(string[] args)
{

const int accountId = XXXX;

var context = new T70Context();

var apiKeyRepo = context.Repository<ApiKey>(new { AccountId = accountId });

var item = new ApiKey()
{

Label = "XXX",

Type = ApiKeyType.Temporary,

ValidTo = DateTime.Now.AddDays(3)

};

apiKeyRepo.Add(item);

}

}