Skip to main content
POST
/
user_data
Go (SDK)
package main

import(
	"context"
	"os"
	latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
	"github.com/latitudesh/latitudesh-go-sdk/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := latitudeshgosdk.New(
        latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
    )

    res, err := s.UserData.CreateNew(ctx, operations.PostUserDataUserDataRequestBody{
        Data: operations.PostUserDataUserDataData{
            Type: operations.PostUserDataUserDataTypeUserData,
            Attributes: &operations.PostUserDataUserDataAttributes{
                Description: "User Data description",
                Project: latitudeshgosdk.Pointer("proj_AW6Q2D9lqKLpr"),
                Content: "I2Nsb3VkLWNvbmZpZwpydW5jbWQ6CiAtIFsgdG91Y2gsICAvaG9tZS91YnVudHUvdGVzdCBd",
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.UserData != nil {
        // handle response
    }
}
{
  "data": {
    "id": "ud_GKN4ydzgqVob3",
    "type": "user_data",
    "attributes": {
      "description": "User Data description",
      "content": "I2Nsb3VkLWNvbmZpZwpydW5jbWQ6CiAtIFsgdG91Y2gsICAvaG9tZS91YnVudHUvdGVzdCBd",
      "created_at": "2025-07-16T18:37:12+00:00",
      "updated_at": "2025-07-16T18:37:12+00:00",
      "decoded_content": "#cloud-config\nruncmd:\n - [ touch,  /home/ubuntu/test ]"
    }
  },
  "meta": {}
}

Authorizations

Authorization
string
header
required

Body

data
object
required

Response

201 - application/vnd.api+json

Created

data
object
meta
object