Zum Hauptinhalt springen

Store a new ssh-key

POST/v2/users/self/ssh-keys
API-Version
v2
Request-Methode
POST
Operation-ID
user-create-ssh-key

Request​

Responses​

Format
application/json
Beschreibung

The ssh-key was stored.

    Content-Type: application/json

    {}
    {
    "type": "object"
    }

    Nutzungsbeispiele​

    $ curl \
    --fail \
    --location \
    -X POST \
    -d '{"expiresAt":"1985-10-26T01:21:00.000Z","publicKey":"ssh-rsa ..."}' \
    -H "Authorization: Bearer $MITTWALD_API_TOKEN" \
    -H 'Content-Type: application/json' \
    https://api.mittwald.de/v2/users/self/ssh-keys
    import { MittwaldAPIV2Client } from "@mittwald/api-client";
    import { assertStatus } from "@mittwald/api-client-commons";

    const client = MittwaldAPIClient.newWithToken(process.env.MITTWALD_API_TOKEN);
    const response = await client.user.createSshKey({
    "data": {
    "expiresAt": "1985-10-26T01:21:00.000Z",
    "publicKey": "ssh-rsa ..."
    }
    });

    assertStatus(response, 201);

    use \Mittwald\ApiClient\Generated\V2\Clients\User\CreateSshKey\CreateSshKeyRequest;
    use \Mittwald\ApiClient\Generated\V2\Clients\User\CreateSshKey\CreateSshKeyRequestBody;

    $client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));

    // TODO: Please consult the properties and constructor signature of
    // CreateSshKeyRequestBody to learn how to construct a valid instance
    $body = new CreateSshKeyRequestBody(/* TODO: ... */);

    $request = (new CreateSshKeyRequest(
    body: $body
    ));
    $response = $client->user()->createSshKey($request);

    var_dump($response->getBody();

    Auf dieser Seite