PingOne Platform APIs

Create multiple OATH tokens

 

POST {{apiPath}}/environments/{{envID}}/oathJobs

This example uses the oathJobs endpoint to submit a job to create multiple tokens. The same endpoint can be used to submit a job to revoke multiple tokens.

The body contains an array called tokens with each object in the array containing the same fields you would use to create a single token.

This example creates both HOTP and TOTP tokens. Note that the hashAlgorithm parameter is included only for the TOTP tokens because currently only HmacSHA1is supported for HOTP tokens.

To check on the status of a submitted job, provide the returned job ID in the URL: {{apiPathTest}}/environments/{{envID}}/oathJobs/{{oathTokenCreationJobID}}

Request Model

Refer to OATH Tokens for the complete data models.

Property Type Required?

hashAlgorithm

String

Optional

hotp

Object

Optional

hotp.counter

Integer

Optional

otpLength

Integer

Required

secret

String

Required

serialNumber

String

Required

totp

Object

Required

totp.timeStep

Integer

Required

type

String

Required

Headers

Authorization      Bearer {{accessToken}}

Content-Type      application/vnd.pingidentity.job.oathtokens.create+json

Body

raw ( application/vnd.pingidentity.job.oathtokens.create+json )

{
    "type": "CREATE_OATH_TOKENS",
    "tokens": [
        {
            "serialNumber": "2308734700388",
            "secret": "6EBD59F71A634C48C4619CD33F6C385C9237C9BA",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2399934700388",
            "secret": "6EBD88F71A634C48C4619CD33F6C385C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 30
            },
            "otpLength": 6,
            "hashAlgorithm": "HmacSHA512"
        },
        {
            "serialNumber": "2308734700397",
            "secret": "6EBD59F71A634C48C4619CB44F6C385C9237C9BC",
            "type": "HOTP",
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700412",
            "secret": "6EBD59F71A634C48C4619CB33F6C356C9237C9BD",
            "type": "HOTP",
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700444",
            "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9CA",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700567",
            "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9AB",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2300004700388",
            "secret": "6EBD88F98A634C48C4619CD33F6C385C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 30
            },
            "otpLength": 6,
            "hashAlgorithm": "HmacSHA512"
        },
        {
            "serialNumber": "2399934700300",
            "secret": "6EBD88F98A634C48C4619CD33F6C388C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 60
            },
            "otpLength": 8,
            "hashAlgorithm": "HmacSHA256"
        }
    ]
}

Example Request

  • cURL

  • C#

  • Go

  • HTTP

  • Java

  • jQuery

  • NodeJS

  • Python

  • PHP

  • Ruby

  • Swift

curl --location --globoff '{{apiPath}}/environments/{{envID}}/oathJobs' \
--header 'Content-Type: application/vnd.pingidentity.job.oathtokens.create+json' \
--header 'Authorization: Bearer {{accessToken}}' \
--data '{
    "type": "CREATE_OATH_TOKENS",
    "tokens": [
        {
            "serialNumber": "2308734700388",
            "secret": "6EBD59F71A634C48C4619CD33F6C385C9237C9BA",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2399934700388",
            "secret": "6EBD88F71A634C48C4619CD33F6C385C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 30
            },
            "otpLength": 6,
            "hashAlgorithm": "HmacSHA512"
        },
        {
            "serialNumber": "2308734700397",
            "secret": "6EBD59F71A634C48C4619CB44F6C385C9237C9BC",
            "type": "HOTP",
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700412",
            "secret": "6EBD59F71A634C48C4619CB33F6C356C9237C9BD",
            "type": "HOTP",
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700444",
            "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9CA",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700567",
            "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9AB",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2300004700388",
            "secret": "6EBD88F98A634C48C4619CD33F6C385C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 30
            },
            "otpLength": 6,
            "hashAlgorithm": "HmacSHA512"
        },
        {
            "serialNumber": "2399934700300",
            "secret": "6EBD88F98A634C48C4619CD33F6C388C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 60
            },
            "otpLength": 8,
            "hashAlgorithm": "HmacSHA256"
        }
    ]
}'
var options = new RestClientOptions("{{apiPath}}/environments/{{envID}}/oathJobs")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Post);
request.AddHeader("Content-Type", "application/vnd.pingidentity.job.oathtokens.create+json");
request.AddHeader("Authorization", "Bearer {{accessToken}}");
var body = @"{" + "\n" +
@"    ""type"": ""CREATE_OATH_TOKENS""," + "\n" +
@"    ""tokens"": [" + "\n" +
@"        {" + "\n" +
@"            ""serialNumber"": ""2308734700388""," + "\n" +
@"            ""secret"": ""6EBD59F71A634C48C4619CD33F6C385C9237C9BA""," + "\n" +
@"            ""type"": ""HOTP""," + "\n" +
@"            ""hotp"": {" + "\n" +
@"                ""counter"": 456789" + "\n" +
@"            }," + "\n" +
@"            ""otpLength"": 8" + "\n" +
@"        }," + "\n" +
@"        {" + "\n" +
@"            ""serialNumber"": ""2399934700388""," + "\n" +
@"            ""secret"": ""6EBD88F71A634C48C4619CD33F6C385C9237C9BA""," + "\n" +
@"            ""type"": ""TOTP""," + "\n" +
@"            ""totp"": {" + "\n" +
@"                ""timeStep"": 30" + "\n" +
@"            }," + "\n" +
@"            ""otpLength"": 6," + "\n" +
@"            ""hashAlgorithm"": ""HmacSHA512""" + "\n" +
@"        }," + "\n" +
@"        {" + "\n" +
@"            ""serialNumber"": ""2308734700397""," + "\n" +
@"            ""secret"": ""6EBD59F71A634C48C4619CB44F6C385C9237C9BC""," + "\n" +
@"            ""type"": ""HOTP""," + "\n" +
@"            ""otpLength"": 8" + "\n" +
@"        }," + "\n" +
@"        {" + "\n" +
@"            ""serialNumber"": ""2308734700412""," + "\n" +
@"            ""secret"": ""6EBD59F71A634C48C4619CB33F6C356C9237C9BD""," + "\n" +
@"            ""type"": ""HOTP""," + "\n" +
@"            ""otpLength"": 8" + "\n" +
@"        }," + "\n" +
@"        {" + "\n" +
@"            ""serialNumber"": ""2308734700444""," + "\n" +
@"            ""secret"": ""6EBD59F71A634C48C4619CB33F6C385C9237C9CA""," + "\n" +
@"            ""type"": ""HOTP""," + "\n" +
@"            ""hotp"": {" + "\n" +
@"                ""counter"": 456789" + "\n" +
@"            }," + "\n" +
@"            ""otpLength"": 8" + "\n" +
@"        }," + "\n" +
@"        {" + "\n" +
@"            ""serialNumber"": ""2308734700567""," + "\n" +
@"            ""secret"": ""6EBD59F71A634C48C4619CB33F6C385C9237C9AB""," + "\n" +
@"            ""type"": ""HOTP""," + "\n" +
@"            ""hotp"": {" + "\n" +
@"                ""counter"": 456789" + "\n" +
@"            }," + "\n" +
@"            ""otpLength"": 8" + "\n" +
@"        }," + "\n" +
@"        {" + "\n" +
@"            ""serialNumber"": ""2300004700388""," + "\n" +
@"            ""secret"": ""6EBD88F98A634C48C4619CD33F6C385C9237C9BA""," + "\n" +
@"            ""type"": ""TOTP""," + "\n" +
@"            ""totp"": {" + "\n" +
@"                ""timeStep"": 30" + "\n" +
@"            }," + "\n" +
@"            ""otpLength"": 6," + "\n" +
@"            ""hashAlgorithm"": ""HmacSHA512""" + "\n" +
@"        },  " + "\n" +
@"        {" + "\n" +
@"            ""serialNumber"": ""2399934700300""," + "\n" +
@"            ""secret"": ""6EBD88F98A634C48C4619CD33F6C388C9237C9BA""," + "\n" +
@"            ""type"": ""TOTP""," + "\n" +
@"            ""totp"": {" + "\n" +
@"                ""timeStep"": 60" + "\n" +
@"            }," + "\n" +
@"            ""otpLength"": 8," + "\n" +
@"            ""hashAlgorithm"": ""HmacSHA256""" + "\n" +
@"        }" + "\n" +
@"    ]" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "{{apiPath}}/environments/{{envID}}/oathJobs"
  method := "POST"

  payload := strings.NewReader(`{
    "type": "CREATE_OATH_TOKENS",
    "tokens": [
        {
            "serialNumber": "2308734700388",
            "secret": "6EBD59F71A634C48C4619CD33F6C385C9237C9BA",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2399934700388",
            "secret": "6EBD88F71A634C48C4619CD33F6C385C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 30
            },
            "otpLength": 6,
            "hashAlgorithm": "HmacSHA512"
        },
        {
            "serialNumber": "2308734700397",
            "secret": "6EBD59F71A634C48C4619CB44F6C385C9237C9BC",
            "type": "HOTP",
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700412",
            "secret": "6EBD59F71A634C48C4619CB33F6C356C9237C9BD",
            "type": "HOTP",
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700444",
            "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9CA",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700567",
            "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9AB",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2300004700388",
            "secret": "6EBD88F98A634C48C4619CD33F6C385C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 30
            },
            "otpLength": 6,
            "hashAlgorithm": "HmacSHA512"
        },
        {
            "serialNumber": "2399934700300",
            "secret": "6EBD88F98A634C48C4619CD33F6C388C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 60
            },
            "otpLength": 8,
            "hashAlgorithm": "HmacSHA256"
        }
    ]
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/vnd.pingidentity.job.oathtokens.create+json")
  req.Header.Add("Authorization", "Bearer {{accessToken}}")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
POST /environments/{{envID}}/oathJobs HTTP/1.1
Host: {{apiPath}}
Content-Type: application/vnd.pingidentity.job.oathtokens.create+json
Authorization: Bearer {{accessToken}}

{
    "type": "CREATE_OATH_TOKENS",
    "tokens": [
        {
            "serialNumber": "2308734700388",
            "secret": "6EBD59F71A634C48C4619CD33F6C385C9237C9BA",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2399934700388",
            "secret": "6EBD88F71A634C48C4619CD33F6C385C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 30
            },
            "otpLength": 6,
            "hashAlgorithm": "HmacSHA512"
        },
        {
            "serialNumber": "2308734700397",
            "secret": "6EBD59F71A634C48C4619CB44F6C385C9237C9BC",
            "type": "HOTP",
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700412",
            "secret": "6EBD59F71A634C48C4619CB33F6C356C9237C9BD",
            "type": "HOTP",
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700444",
            "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9CA",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2308734700567",
            "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9AB",
            "type": "HOTP",
            "hotp": {
                "counter": 456789
            },
            "otpLength": 8
        },
        {
            "serialNumber": "2300004700388",
            "secret": "6EBD88F98A634C48C4619CD33F6C385C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 30
            },
            "otpLength": 6,
            "hashAlgorithm": "HmacSHA512"
        },
        {
            "serialNumber": "2399934700300",
            "secret": "6EBD88F98A634C48C4619CD33F6C388C9237C9BA",
            "type": "TOTP",
            "totp": {
                "timeStep": 60
            },
            "otpLength": 8,
            "hashAlgorithm": "HmacSHA256"
        }
    ]
}
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/vnd.pingidentity.job.oathtokens.create+json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"type\": \"CREATE_OATH_TOKENS\",\n    \"tokens\": [\n        {\n            \"serialNumber\": \"2308734700388\",\n            \"secret\": \"6EBD59F71A634C48C4619CD33F6C385C9237C9BA\",\n            \"type\": \"HOTP\",\n            \"hotp\": {\n                \"counter\": 456789\n            },\n            \"otpLength\": 8\n        },\n        {\n            \"serialNumber\": \"2399934700388\",\n            \"secret\": \"6EBD88F71A634C48C4619CD33F6C385C9237C9BA\",\n            \"type\": \"TOTP\",\n            \"totp\": {\n                \"timeStep\": 30\n            },\n            \"otpLength\": 6,\n            \"hashAlgorithm\": \"HmacSHA512\"\n        },\n        {\n            \"serialNumber\": \"2308734700397\",\n            \"secret\": \"6EBD59F71A634C48C4619CB44F6C385C9237C9BC\",\n            \"type\": \"HOTP\",\n            \"otpLength\": 8\n        },\n        {\n            \"serialNumber\": \"2308734700412\",\n            \"secret\": \"6EBD59F71A634C48C4619CB33F6C356C9237C9BD\",\n            \"type\": \"HOTP\",\n            \"otpLength\": 8\n        },\n        {\n            \"serialNumber\": \"2308734700444\",\n            \"secret\": \"6EBD59F71A634C48C4619CB33F6C385C9237C9CA\",\n            \"type\": \"HOTP\",\n            \"hotp\": {\n                \"counter\": 456789\n            },\n            \"otpLength\": 8\n        },\n        {\n            \"serialNumber\": \"2308734700567\",\n            \"secret\": \"6EBD59F71A634C48C4619CB33F6C385C9237C9AB\",\n            \"type\": \"HOTP\",\n            \"hotp\": {\n                \"counter\": 456789\n            },\n            \"otpLength\": 8\n        },\n        {\n            \"serialNumber\": \"2300004700388\",\n            \"secret\": \"6EBD88F98A634C48C4619CD33F6C385C9237C9BA\",\n            \"type\": \"TOTP\",\n            \"totp\": {\n                \"timeStep\": 30\n            },\n            \"otpLength\": 6,\n            \"hashAlgorithm\": \"HmacSHA512\"\n        },  \n        {\n            \"serialNumber\": \"2399934700300\",\n            \"secret\": \"6EBD88F98A634C48C4619CD33F6C388C9237C9BA\",\n            \"type\": \"TOTP\",\n            \"totp\": {\n                \"timeStep\": 60\n            },\n            \"otpLength\": 8,\n            \"hashAlgorithm\": \"HmacSHA256\"\n        }\n    ]\n}");
Request request = new Request.Builder()
  .url("{{apiPath}}/environments/{{envID}}/oathJobs")
  .method("POST", body)
  .addHeader("Content-Type", "application/vnd.pingidentity.job.oathtokens.create+json")
  .addHeader("Authorization", "Bearer {{accessToken}}")
  .build();
Response response = client.newCall(request).execute();
var settings = {
  "url": "{{apiPath}}/environments/{{envID}}/oathJobs",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/vnd.pingidentity.job.oathtokens.create+json",
    "Authorization": "Bearer {{accessToken}}"
  },
  "data": JSON.stringify({
    "type": "CREATE_OATH_TOKENS",
    "tokens": [
      {
        "serialNumber": "2308734700388",
        "secret": "6EBD59F71A634C48C4619CD33F6C385C9237C9BA",
        "type": "HOTP",
        "hotp": {
          "counter": 456789
        },
        "otpLength": 8
      },
      {
        "serialNumber": "2399934700388",
        "secret": "6EBD88F71A634C48C4619CD33F6C385C9237C9BA",
        "type": "TOTP",
        "totp": {
          "timeStep": 30
        },
        "otpLength": 6,
        "hashAlgorithm": "HmacSHA512"
      },
      {
        "serialNumber": "2308734700397",
        "secret": "6EBD59F71A634C48C4619CB44F6C385C9237C9BC",
        "type": "HOTP",
        "otpLength": 8
      },
      {
        "serialNumber": "2308734700412",
        "secret": "6EBD59F71A634C48C4619CB33F6C356C9237C9BD",
        "type": "HOTP",
        "otpLength": 8
      },
      {
        "serialNumber": "2308734700444",
        "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9CA",
        "type": "HOTP",
        "hotp": {
          "counter": 456789
        },
        "otpLength": 8
      },
      {
        "serialNumber": "2308734700567",
        "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9AB",
        "type": "HOTP",
        "hotp": {
          "counter": 456789
        },
        "otpLength": 8
      },
      {
        "serialNumber": "2300004700388",
        "secret": "6EBD88F98A634C48C4619CD33F6C385C9237C9BA",
        "type": "TOTP",
        "totp": {
          "timeStep": 30
        },
        "otpLength": 6,
        "hashAlgorithm": "HmacSHA512"
      },
      {
        "serialNumber": "2399934700300",
        "secret": "6EBD88F98A634C48C4619CD33F6C388C9237C9BA",
        "type": "TOTP",
        "totp": {
          "timeStep": 60
        },
        "otpLength": 8,
        "hashAlgorithm": "HmacSHA256"
      }
    ]
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require('request');
var options = {
  'method': 'POST',
  'url': '{{apiPath}}/environments/{{envID}}/oathJobs',
  'headers': {
    'Content-Type': 'application/vnd.pingidentity.job.oathtokens.create+json',
    'Authorization': 'Bearer {{accessToken}}'
  },
  body: JSON.stringify({
    "type": "CREATE_OATH_TOKENS",
    "tokens": [
      {
        "serialNumber": "2308734700388",
        "secret": "6EBD59F71A634C48C4619CD33F6C385C9237C9BA",
        "type": "HOTP",
        "hotp": {
          "counter": 456789
        },
        "otpLength": 8
      },
      {
        "serialNumber": "2399934700388",
        "secret": "6EBD88F71A634C48C4619CD33F6C385C9237C9BA",
        "type": "TOTP",
        "totp": {
          "timeStep": 30
        },
        "otpLength": 6,
        "hashAlgorithm": "HmacSHA512"
      },
      {
        "serialNumber": "2308734700397",
        "secret": "6EBD59F71A634C48C4619CB44F6C385C9237C9BC",
        "type": "HOTP",
        "otpLength": 8
      },
      {
        "serialNumber": "2308734700412",
        "secret": "6EBD59F71A634C48C4619CB33F6C356C9237C9BD",
        "type": "HOTP",
        "otpLength": 8
      },
      {
        "serialNumber": "2308734700444",
        "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9CA",
        "type": "HOTP",
        "hotp": {
          "counter": 456789
        },
        "otpLength": 8
      },
      {
        "serialNumber": "2308734700567",
        "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9AB",
        "type": "HOTP",
        "hotp": {
          "counter": 456789
        },
        "otpLength": 8
      },
      {
        "serialNumber": "2300004700388",
        "secret": "6EBD88F98A634C48C4619CD33F6C385C9237C9BA",
        "type": "TOTP",
        "totp": {
          "timeStep": 30
        },
        "otpLength": 6,
        "hashAlgorithm": "HmacSHA512"
      },
      {
        "serialNumber": "2399934700300",
        "secret": "6EBD88F98A634C48C4619CD33F6C388C9237C9BA",
        "type": "TOTP",
        "totp": {
          "timeStep": 60
        },
        "otpLength": 8,
        "hashAlgorithm": "HmacSHA256"
      }
    ]
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests
import json

url = "{{apiPath}}/environments/{{envID}}/oathJobs"

payload = json.dumps({
  "type": "CREATE_OATH_TOKENS",
  "tokens": [
    {
      "serialNumber": "2308734700388",
      "secret": "6EBD59F71A634C48C4619CD33F6C385C9237C9BA",
      "type": "HOTP",
      "hotp": {
        "counter": 456789
      },
      "otpLength": 8
    },
    {
      "serialNumber": "2399934700388",
      "secret": "6EBD88F71A634C48C4619CD33F6C385C9237C9BA",
      "type": "TOTP",
      "totp": {
        "timeStep": 30
      },
      "otpLength": 6,
      "hashAlgorithm": "HmacSHA512"
    },
    {
      "serialNumber": "2308734700397",
      "secret": "6EBD59F71A634C48C4619CB44F6C385C9237C9BC",
      "type": "HOTP",
      "otpLength": 8
    },
    {
      "serialNumber": "2308734700412",
      "secret": "6EBD59F71A634C48C4619CB33F6C356C9237C9BD",
      "type": "HOTP",
      "otpLength": 8
    },
    {
      "serialNumber": "2308734700444",
      "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9CA",
      "type": "HOTP",
      "hotp": {
        "counter": 456789
      },
      "otpLength": 8
    },
    {
      "serialNumber": "2308734700567",
      "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9AB",
      "type": "HOTP",
      "hotp": {
        "counter": 456789
      },
      "otpLength": 8
    },
    {
      "serialNumber": "2300004700388",
      "secret": "6EBD88F98A634C48C4619CD33F6C385C9237C9BA",
      "type": "TOTP",
      "totp": {
        "timeStep": 30
      },
      "otpLength": 6,
      "hashAlgorithm": "HmacSHA512"
    },
    {
      "serialNumber": "2399934700300",
      "secret": "6EBD88F98A634C48C4619CD33F6C388C9237C9BA",
      "type": "TOTP",
      "totp": {
        "timeStep": 60
      },
      "otpLength": 8,
      "hashAlgorithm": "HmacSHA256"
    }
  ]
})
headers = {
  'Content-Type': 'application/vnd.pingidentity.job.oathtokens.create+json',
  'Authorization': 'Bearer {{accessToken}}'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{{apiPath}}/environments/{{envID}}/oathJobs');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Content-Type' => 'application/vnd.pingidentity.job.oathtokens.create+json',
  'Authorization' => 'Bearer {{accessToken}}'
));
$request->setBody('{\n    "type": "CREATE_OATH_TOKENS",\n    "tokens": [\n        {\n            "serialNumber": "2308734700388",\n            "secret": "6EBD59F71A634C48C4619CD33F6C385C9237C9BA",\n            "type": "HOTP",\n            "hotp": {\n                "counter": 456789\n            },\n            "otpLength": 8\n        },\n        {\n            "serialNumber": "2399934700388",\n            "secret": "6EBD88F71A634C48C4619CD33F6C385C9237C9BA",\n            "type": "TOTP",\n            "totp": {\n                "timeStep": 30\n            },\n            "otpLength": 6,\n            "hashAlgorithm": "HmacSHA512"\n        },\n        {\n            "serialNumber": "2308734700397",\n            "secret": "6EBD59F71A634C48C4619CB44F6C385C9237C9BC",\n            "type": "HOTP",\n            "otpLength": 8\n        },\n        {\n            "serialNumber": "2308734700412",\n            "secret": "6EBD59F71A634C48C4619CB33F6C356C9237C9BD",\n            "type": "HOTP",\n            "otpLength": 8\n        },\n        {\n            "serialNumber": "2308734700444",\n            "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9CA",\n            "type": "HOTP",\n            "hotp": {\n                "counter": 456789\n            },\n            "otpLength": 8\n        },\n        {\n            "serialNumber": "2308734700567",\n            "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9AB",\n            "type": "HOTP",\n            "hotp": {\n                "counter": 456789\n            },\n            "otpLength": 8\n        },\n        {\n            "serialNumber": "2300004700388",\n            "secret": "6EBD88F98A634C48C4619CD33F6C385C9237C9BA",\n            "type": "TOTP",\n            "totp": {\n                "timeStep": 30\n            },\n            "otpLength": 6,\n            "hashAlgorithm": "HmacSHA512"\n        },  \n        {\n            "serialNumber": "2399934700300",\n            "secret": "6EBD88F98A634C48C4619CD33F6C388C9237C9BA",\n            "type": "TOTP",\n            "totp": {\n                "timeStep": 60\n            },\n            "otpLength": 8,\n            "hashAlgorithm": "HmacSHA256"\n        }\n    ]\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
require "uri"
require "json"
require "net/http"

url = URI("{{apiPath}}/environments/{{envID}}/oathJobs")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/vnd.pingidentity.job.oathtokens.create+json"
request["Authorization"] = "Bearer {{accessToken}}"
request.body = JSON.dump({
  "type": "CREATE_OATH_TOKENS",
  "tokens": [
    {
      "serialNumber": "2308734700388",
      "secret": "6EBD59F71A634C48C4619CD33F6C385C9237C9BA",
      "type": "HOTP",
      "hotp": {
        "counter": 456789
      },
      "otpLength": 8
    },
    {
      "serialNumber": "2399934700388",
      "secret": "6EBD88F71A634C48C4619CD33F6C385C9237C9BA",
      "type": "TOTP",
      "totp": {
        "timeStep": 30
      },
      "otpLength": 6,
      "hashAlgorithm": "HmacSHA512"
    },
    {
      "serialNumber": "2308734700397",
      "secret": "6EBD59F71A634C48C4619CB44F6C385C9237C9BC",
      "type": "HOTP",
      "otpLength": 8
    },
    {
      "serialNumber": "2308734700412",
      "secret": "6EBD59F71A634C48C4619CB33F6C356C9237C9BD",
      "type": "HOTP",
      "otpLength": 8
    },
    {
      "serialNumber": "2308734700444",
      "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9CA",
      "type": "HOTP",
      "hotp": {
        "counter": 456789
      },
      "otpLength": 8
    },
    {
      "serialNumber": "2308734700567",
      "secret": "6EBD59F71A634C48C4619CB33F6C385C9237C9AB",
      "type": "HOTP",
      "hotp": {
        "counter": 456789
      },
      "otpLength": 8
    },
    {
      "serialNumber": "2300004700388",
      "secret": "6EBD88F98A634C48C4619CD33F6C385C9237C9BA",
      "type": "TOTP",
      "totp": {
        "timeStep": 30
      },
      "otpLength": 6,
      "hashAlgorithm": "HmacSHA512"
    },
    {
      "serialNumber": "2399934700300",
      "secret": "6EBD88F98A634C48C4619CD33F6C388C9237C9BA",
      "type": "TOTP",
      "totp": {
        "timeStep": 60
      },
      "otpLength": 8,
      "hashAlgorithm": "HmacSHA256"
    }
  ]
})

response = http.request(request)
puts response.read_body
let parameters = "{\n    \"type\": \"CREATE_OATH_TOKENS\",\n    \"tokens\": [\n        {\n            \"serialNumber\": \"2308734700388\",\n            \"secret\": \"6EBD59F71A634C48C4619CD33F6C385C9237C9BA\",\n            \"type\": \"HOTP\",\n            \"hotp\": {\n                \"counter\": 456789\n            },\n            \"otpLength\": 8\n        },\n        {\n            \"serialNumber\": \"2399934700388\",\n            \"secret\": \"6EBD88F71A634C48C4619CD33F6C385C9237C9BA\",\n            \"type\": \"TOTP\",\n            \"totp\": {\n                \"timeStep\": 30\n            },\n            \"otpLength\": 6,\n            \"hashAlgorithm\": \"HmacSHA512\"\n        },\n        {\n            \"serialNumber\": \"2308734700397\",\n            \"secret\": \"6EBD59F71A634C48C4619CB44F6C385C9237C9BC\",\n            \"type\": \"HOTP\",\n            \"otpLength\": 8\n        },\n        {\n            \"serialNumber\": \"2308734700412\",\n            \"secret\": \"6EBD59F71A634C48C4619CB33F6C356C9237C9BD\",\n            \"type\": \"HOTP\",\n            \"otpLength\": 8\n        },\n        {\n            \"serialNumber\": \"2308734700444\",\n            \"secret\": \"6EBD59F71A634C48C4619CB33F6C385C9237C9CA\",\n            \"type\": \"HOTP\",\n            \"hotp\": {\n                \"counter\": 456789\n            },\n            \"otpLength\": 8\n        },\n        {\n            \"serialNumber\": \"2308734700567\",\n            \"secret\": \"6EBD59F71A634C48C4619CB33F6C385C9237C9AB\",\n            \"type\": \"HOTP\",\n            \"hotp\": {\n                \"counter\": 456789\n            },\n            \"otpLength\": 8\n        },\n        {\n            \"serialNumber\": \"2300004700388\",\n            \"secret\": \"6EBD88F98A634C48C4619CD33F6C385C9237C9BA\",\n            \"type\": \"TOTP\",\n            \"totp\": {\n                \"timeStep\": 30\n            },\n            \"otpLength\": 6,\n            \"hashAlgorithm\": \"HmacSHA512\"\n        },  \n        {\n            \"serialNumber\": \"2399934700300\",\n            \"secret\": \"6EBD88F98A634C48C4619CD33F6C388C9237C9BA\",\n            \"type\": \"TOTP\",\n            \"totp\": {\n                \"timeStep\": 60\n            },\n            \"otpLength\": 8,\n            \"hashAlgorithm\": \"HmacSHA256\"\n        }\n    ]\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "{{apiPath}}/environments/{{envID}}/oathJobs")!,timeoutInterval: Double.infinity)
request.addValue("application/vnd.pingidentity.job.oathtokens.create+json", forHTTPHeaderField: "Content-Type")
request.addValue("Bearer {{accessToken}}", forHTTPHeaderField: "Authorization")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

Example Response

202 Accepted

{
    "_links": {
        "self": {
            "href": "https://api.test-one-pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/jobs/fb8583a6-ac7a-4954-b321-092752936f3c"
        },
        "environment": {
            "href": "https://api.test-one-pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
        }
    },
    "id": "fb8583a6-ac7a-4954-b321-092752936f3c",
    "environment": {
        "id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
    },
    "type": "CREATE_OATH_TOKENS",
    "async": true,
    "status": "PENDING",
    "result": {
        "created": 0
    }
}